scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Can't use nightly build of dotty as a runtime dependency from 2.13.8 #12542

Open adampauls opened 2 years ago

adampauls commented 2 years ago

reproduction steps

Include a nightly build of dotty as a runtime dependency using "org.scala-lang" %% "scala3-compiler" % "3.1.3-RC1-bin-20220221-3ca087c-NIGHTLY".

In a program run with Scala 2.13.8.

problem

I get this error message

[error] TASTy signature has wrong version.
[error]  expected: {majorVersion: 28, minorVersion: 1}
[error]  found   : {majorVersion: 28, minorVersion: 2 [unstable release: 1]}

I think this is probably intended behavior, but it would be nice if there were a way to work around it to experiment with nightlies.

SethTisue commented 2 years ago

@bishabosha is this expected?

SethTisue commented 2 years ago

Dale notes that there is doc at https://github.com/lampepfl/dotty/blob/main/tasty/src/dotty/tools/tasty/TastyFormat.scala#L311-L344

One thing it says is:

A compiler with a stable TASTy version can never read a file with an unstable TASTy version

Whoever wrote that probably wasn't even thinking about Scala 2 at all, but arguably this is working as designed.

I suppose one could argue that Scala 2 nightlies ought to be able to read unstable TASTy, and we ought to only disable that in our actual releases. But in Scala 2, we don't currently have any code which distinguishes release builds from nightly builds, so there isn't an existing switch we can flip here, and I'm not sure there's sufficient motivation here to introduce one.

I'd suggest building your own Scala 2 locally and disabling the check. But I'm not positive that I would oppose introducing a trapdoor. I'm curious what this is really about, what is your true goal here...?

adampauls commented 2 years ago

It's a bit of a long story, but basically we really just want a version of Scala meta that is error-tolerant like dotty's Parser is (so we can use it for autocomplete and such). Since that doesn't exist, we decided to actually just use dotty. This works fine on a stable version, but I wanted to test out a few bug fixes before 3.1.3 or 3.2.0 come out. I did manage to build the non-bootstrapped version of dotty locally and test everything out, but I was hoping to be able to depend on a nightly for a little while without having to do the dance.

I can totally understand not wanting to fix this issue since my use here is very off-label, I was just hoping there was a backdoor. I don't see much downside to a -Ytasty-reader -Yunstable-tasty option, but it's more work than nothing, so I can't complain too much!

SethTisue commented 2 years ago

ping @bishabosha

bishabosha commented 2 years ago

Hey, so yes it is the intended behaviour that Scala 2 compiler should only be able to read the latest stable release it knows about, but I'll be happy to add a flag that disables the check under a flag - users would have to be aware to never use this flag to depend on something if they intend to publish a library