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

Self-assignment of this has been cruelly outlawed #18891

Open
som-snytt opened this issue Nov 10, 2023 · 4 comments
Open

Self-assignment of this has been cruelly outlawed #18891

som-snytt opened this issue Nov 10, 2023 · 4 comments
Labels
area:spec backlog No work planned on this by the core team for the time being. itype:bug

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.4.0-RC1-bin-SNAPSHOT-git-5454110

Minimized code

Welcome to Scala 3.4.0-RC1-bin-SNAPSHOT-git-5454110 (21, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> val this = this
-- [E040] Syntax Error: ------------------------------------------------------------------------------------------------
1 |val this = this
  |    ^
  |    an identifier expected, but 'this' found
  |
  | longer explanation available when compiling with `-explain`

scala>

Expectation

Don't disallow keywords which are patterns.

#12406

#18752

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 10, 2023
@Kordyjan
Copy link
Contributor

I should probably classify this as a bug in the parser, but I feel this is a morally wrong thing to do.

@Kordyjan Kordyjan added area:parser and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 10, 2023
@nicolasstucki
Copy link
Contributor

Maybe the following message would be clearer

 an identifier expected, but 'this' keyword found

@Kordyjan
Copy link
Contributor

Is this the only case where the pattern can start with something other than an identifier?

@dwijnand dwijnand added backlog No work planned on this by the core team for the time being. area:spec and removed area:parser labels Nov 13, 2023
@bishabosha
Copy link
Member

you can also have val 1 = 1, val true = true, val null = null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:spec backlog No work planned on this by the core team for the time being. itype:bug
Projects
None yet
Development

No branches or pull requests

5 participants