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

REPL compiler crash IllegalArgumentException when declaring collective extensions 2 defs and then same names as 2 vals #19184

Closed
bjornregnell opened this issue Dec 4, 2023 · 0 comments · Fixed by #20543

Comments

@bjornregnell
Copy link
Contributor

Compiler version

3.3.1 and 3.4.0-RC1-bin-20231201-d96e9e4-NIGHTLY

Minimized code + Output

$ scala-cli -S 3.nightly
Downloading Scala 3.4.0-RC1-bin-20231201-d96e9e4-NIGHTLY compiler
Welcome to Scala 3.4.0-RC1-bin-20231201-d96e9e4-NIGHTLY-git-d96e9e4 (17.0.8.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                                              
scala> extension (s: String) 
     |   def o = s + "o"
     |   def oo = s + "oo"
     | val o = "o"
     | val oo = "oo"
Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at dotty.tools.repl.Rendering.$anonfun$4(Rendering.scala:110)
    at scala.Option.flatMap(Option.scala:283)
    at dotty.tools.repl.Rendering.valueOf(Rendering.scala:110)
    at dotty.tools.repl.Rendering.renderVal(Rendering.scala:152)
    at dotty.tools.repl.ReplDriver.$anonfun$7(ReplDriver.scala:390)
    at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
    at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
    at scala.collection.immutable.List.foreach(List.scala:333)

Expectation

The compiler should not crash. The code should work just as in:

$ scala-cli -S 3.nightly
Welcome to Scala 3.4.0-RC1-bin-20231201-d96e9e4-NIGHTLY-git-d96e9e4 (17.0.8.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                                              
scala> extension (s: String) 
     |   def oo = s + "oo"
     | val oo = "oo"
def oo(s: String): String
val oo: String = oo
@bjornregnell bjornregnell added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 4, 2023
@hamzaremmal hamzaremmal added area:repl and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 4, 2023
mbovel added a commit to mbovel/dotty that referenced this issue Jun 10, 2024
valueOf should only consider getters, which have 0 parameters.

test with:
scala3-compiler / testOnly dotty.tools.repl.ScriptedTests -- dotty.tools.repl.ScriptedTests.replTests

Fixes scala#19184
@mbovel mbovel closed this as completed in 4828244 Jul 1, 2024
@Kordyjan Kordyjan added this to the 3.5.1 milestone Jul 3, 2024
WojciechMazur pushed a commit that referenced this issue Jul 10, 2024
`valueOf` should only consider getters, which have 0 parameters.

test with:
```
scala3-compiler / testOnly dotty.tools.repl.ScriptedTests -- dotty.tools.repl.ScriptedTests.replTests
```

Fixes #19184
[Cherry-picked 4828244]
WojciechMazur pushed a commit that referenced this issue Jul 10, 2024
`valueOf` should only consider getters, which have 0 parameters.

test with:
```
scala3-compiler / testOnly dotty.tools.repl.ScriptedTests -- dotty.tools.repl.ScriptedTests.replTests
```

Fixes #19184
[Cherry-picked 4828244]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants