Skip to content

Illegal modifier on local def #4815

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
allanrenucci opened this issue Jul 19, 2018 · 0 comments
Closed

Illegal modifier on local def #4815

allanrenucci opened this issue Jul 19, 2018 · 0 comments

Comments

@allanrenucci
Copy link
Contributor

scalac doesn't let you write:

class Test {
  def foo = {
    final def bar = 1
  }
}
> scalac Test.scala
Test.scala:3: error: expected start of definition
    final def bar = 1
          ^
one error found

But Dotty does...

abeln added a commit to abeln/dotty that referenced this issue Jul 26, 2018
During typechecking, disallow the use of "final" in local "defs".

e.g.

def foo = {
  final def bar = 42 // error: final in local def is disallowed
}
abeln added a commit to abeln/dotty that referenced this issue Jul 27, 2018
During parsing, disallow the use of "final" in local definitions.

e.g.

def foo = {
  final def bar = 42 // error: final in local def is disallowed
  final var x = 42 // error
  final type X = Int // error
}
allanrenucci added a commit that referenced this issue Jul 27, 2018
Fix #4815: Illegal modifier on local def
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