Skip to content

Using identifiers starting with "res" in the REPL can lead to issues #3536

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

Closed
smarter opened this issue Nov 23, 2017 · 4 comments · Fixed by #13600
Closed

Using identifiers starting with "res" in the REPL can lead to issues #3536

smarter opened this issue Nov 23, 2017 · 4 comments · Fixed by #13600

Comments

@smarter
Copy link
Member

smarter commented Nov 23, 2017

For example:

scala> val res0 = 1 
val res0: Int = 1
scala> res0 
1 |res0
  |^^^^
  |recursive value res0 needs type

Similar issues exist in the Scala 2.12.4 REPL and in Ammonite so there's probably no easy solution here :).

@smarter smarter changed the title Using identifiers starting with "res" names in the REPL can lead to issues Using identifiers starting with "res" in the REPL can lead to issues Nov 23, 2017
@dwijnand
Copy link
Member

dwijnand commented Sep 8, 2021

No easy solution? What about using $res? Or even just a mangled name of some form? Security by obscurity, sure, but there's value in just making it harder to do the wrong thing.

@smarter
Copy link
Member Author

smarter commented Sep 8, 2021

I wouldn't want to encourage users to type identifiers with dollars in them when they want to refer to a previous line in the repl

@dwijnand
Copy link
Member

dwijnand commented Sep 8, 2021

Sorry, for some reason I thought this was about accidentally name clashing, not about referring to existing results.

@dwijnand dwijnand self-assigned this Sep 8, 2021
@SethTisue
Copy link
Member

SethTisue commented Sep 23, 2021

as you might expect, val (res0, ...) = ... and def res0 and object res0 and var res0 and type res0 (and...?) are also affected

@dwijnand dwijnand linked a pull request Sep 23, 2021 that will close this issue
@Kordyjan Kordyjan added this to the 3.1.1 milestone Aug 2, 2023
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