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

Compiler should not allow to define @volatile val #19416

Closed
WojciechMazur opened this issue Jan 10, 2024 · 2 comments · Fixed by #19462
Closed

Compiler should not allow to define @volatile val #19416

WojciechMazur opened this issue Jan 10, 2024 · 2 comments · Fixed by #19462

Comments

@WojciechMazur
Copy link
Contributor

@volatile annotation only makes sense on variables. The compiler should not allow to use this annotation on immutable val field.

Compiler version

All Scala 3 versions

Minimized code

class Foo:
  @volatile val x: Int = ???

Output

No warnings

Expectation

Give the same error as Scala 2:

./main.scala:2: error: values cannot be volatile
  @volatile val x: Int = ???
                ^
@WojciechMazur WojciechMazur added itype:bug itype:enhancement area:parser good first issue Perfect for someone who wants to get started contributing labels Jan 10, 2024
@nicolasstucki nicolasstucki added the Spree Suitable for a future Spree label Jan 11, 2024
@scala-center-bot
Copy link

scala-center-bot commented Jan 14, 2024

This issue was picked for the Issue Spree No. 41 of January 16th, 2024 which takes place in 2 days. @mbovel, @AnotherMedo will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here.

@mbovel
Copy link
Member

mbovel commented Jan 16, 2024

We can probably check it from RefChecks.transformValDef.

@mbovel mbovel removed Spree Suitable for a future Spree good first issue Perfect for someone who wants to get started contributing labels Jan 30, 2024
hamzaremmal added a commit that referenced this issue Feb 1, 2024
Fixes #19416

Co-authored-by: Mehdi Alaoui <mehdi.alaoui@epfl.ch>
Co-authored-by: Matt Bovel <matthieu@bovel.net>
@Kordyjan Kordyjan added this to the 3.4.1 milestone Feb 14, 2024
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