Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 3.4.0 can't load $ symbol classfile #19702

Closed
rochala opened this issue Feb 15, 2024 · 3 comments · Fixed by #19705
Closed

Scala 3.4.0 can't load $ symbol classfile #19702

rochala opened this issue Feb 15, 2024 · 3 comments · Fixed by #19705
Assignees
Labels
area:tasty-format issues relating to TASTy as a portable standard itype:invalid
Milestone

Comments

@rochala
Copy link
Contributor

rochala commented Feb 15, 2024

Compiler version

3.4.0

Minimized code

file: Test.scala

//> using scala 3.4.0

package test

object $ {
  def test(): Int = 1
}

into:
scala-cli package --library Test.scala

into:

file: TestTest.scala

//> using jar "Test.jar"
//> using scala 3.4

@main def hello =
  test.$.test()

  println("?")

Output (click arrow to expand)

❯ scala-cli run TestTest.scala
Compiling project (Scala 3.4.0, JVM (17))
Error: Loading Scala 3 binary from /Users/jrochala/Projects/scala-cli-telemetry-test/Test.jar(test/$.class). It should have been loaded from `.tasty` file. This `.tasty` file is missing. Try cleaning the project to fix this issue.
Error compiling project (Scala 3.4.0, JVM (17))
Compilation failed

Additional info:

I'm not sure whether we should count this as regression as dollar is reserved for compiler-synthesized identifiers. User programs should not define identifiers which contain ‘$’ characters.

Even tho it affected ammonite:
https://github.com/com-lihaoyi/Ammonite/actions/runs/7914125865/job/21603222806?pr=1394#step:4:3164

Probably caused by changes in f9e8b36

@rochala rochala added itype:bug area:tasty-format issues relating to TASTy as a portable standard regression This worked in a previous version but doesn't anymore labels Feb 15, 2024
@nicolasstucki
Copy link
Contributor

As pointed out, the specification states that object $ is not allowed and therefore has undefined behavior. This object must be deprecated as soon as possible because it will be impossible to guarantee it works.

We might be able to patch the current failure. I will try it. But this would only be a temporary patch.

What is the status of the lining rule that detects names containing $?

@nicolasstucki
Copy link
Contributor

Opened com-lihaoyi/Ammonite#1395 to track progress on Ammonite side.

@rochala
Copy link
Contributor Author

rochala commented Feb 16, 2024

This is the PR that is supposed to add this warning #18563

bishabosha added a commit that referenced this issue Feb 19, 2024
Add an ad-hoc patch to make it possible to use the broken `object $`
definitions in
https://github.com/com-lihaoyi/Ammonite/blob/main/amm/interp/api/src/main/scala/ammonite/Stubs.scala.

This is a temporary patch while these definitions get deprecated. There
is not guarantee that the semantics of these objects are correct. There
is also no way to adapt the spec to allow there definition without
breaking the language. For example consider `object $` and `object $$`,
how would we know if the `$$.class` is the class of `$$` or the module
class of `$`. We need to know this before we read the file.

Closes #19702
@Kordyjan Kordyjan modified the milestones: 3.4.1, 3.4.2 Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:tasty-format issues relating to TASTy as a portable standard itype:invalid
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants