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 unhygienic result names #22858

Open
som-snytt opened this issue Mar 22, 2025 · 0 comments
Open

REPL unhygienic result names #22858

som-snytt opened this issue Mar 22, 2025 · 0 comments

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.6.4

Minimized code

Welcome to Scala 3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped-git-eb2c406 (23.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> List(res0).map: i =>
     |   i+1
     |
-- [E045] Cyclic Error: --------------------------------------------------------
1 |List(res0).map: i =>
  |     ^
  |     Recursive value res0 needs type
  |
  |      Run with -explain-cyclic for more details.
  |
  | longer explanation available when compiling with `-explain`
1 error found

That was by accidentally back-arrow into history. Simpler if less realistic:

Welcome to Scala 3.6.4 (23.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> res0
-- [E045] Cyclic Error: --------------------------------------------------------
1 |res0
  |^
  |Recursive value res0 needs type
  |
  | Run with -explain-cyclic for more details.
  |
  | longer explanation available when compiling with `-explain`
1 error found

Output

As shown.

Expectation

REPL could be more hygienic about "result" names. Scala 2 makes some accommodations for pasting code, but also demonstrates this problem.

This would be a more interesting bug if REPL supported re-evaluation by mutating inputs from history, more like a spreadsheet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant