-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Strange behaviour in repl when using fewerBraces, first it does not work then it does #14491
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
Comments
That is a new twist on #13097 |
Indeed a twisty twist 🔀 |
The middle step of creating the lambda does not seem to be necessary: scala> import language.experimental.fewerBraces
scala> Seq(7,8,9).apply:
| 1
-- Error: ----------------------------------------------------------------------
1 |Seq(7,8,9).apply:
|^^^^^^^^^^^^^^^^
|missing arguments for method apply in trait SeqOps
1 error found
scala> Seq(7,8,9).apply:
| 1
|
val res0: Int = 8
scala> :reset
scala> import language.experimental.fewerBraces
scala> Seq(7,8,9).apply:
| 1
-- Error: ----------------------------------------------------------------------
1 |Seq(7,8,9).apply:
|^^^^^^^^^^^^^^^^
|missing arguments for method apply in trait SeqOps
1 error found The first time the expression is entered in the REPL the parsed tree looks like
whereas when re-entered it parses into
Seems like some sort of resident compiler glitch. |
The issue does not manifest if fewer braces support is enabled by starting the REPL with the |
So, the issue has to do with how import statements from previous REPL lines are brought into the compiler context. This happens here: where the user defined imports from previous lines are folded into the rootContext for the new compiler run. However, the REPL is special in that the Parser is run standalone rather than as part of the frontend phases of the compiler, which in turn means that the REPL parser is not seeing an up-to-date context since the next run of the compiler has not yet started. scala> import language.experimental.fewerBraces
scala> "hello"
val res0: String = hello
scala> Seq(7,8,9).apply:
| 1
|
val res1: Int = 8 The issue does not manifest in the example above because the import is brought into context during compilation of the line containing "hello". Indeed the issue is only present when the code on the REPL line immediately following the fewerBraces import requires fewerBraces to be enabled. |
Compiler version
Scala 3.1.3-RC1-bin-SNAPSHOT-nonbootstrapped-git-ccd39b7
usingrepl
insbt
from current dotty repo.Minimized code and output
Expectation
The first try above should work. Now it first does not work as expected; then it starts working after creating the first lambda by providing an empty arg.
Maybe it is cased by some kind of jline parsing issue?
The text was updated successfully, but these errors were encountered: