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
Late Initialization of Vals #399
Comments
Imported From: https://issues.scala-lang.org/browse/SI-399?orig=1
|
@michael-nischt said: |
Geoffrey Alan Washburn (washburn) said: |
@michael-nischt said:
Really, I mean this is a source of unnecessary bugs. Futhermore it breaks the contract of vals, because the value changes from the default to the assigned. Actually, I would strongly recommend to make it result in a compile error 'undeclared', as it isn't a that time. |
Geoffrey Alan Washburn (washburn) said: class Foo {
println ( this.foo )
val foo = 1
} It is less than ideal, but we have discussed the problem, and I am told that attempts to fix this have been made in the past, and given the limitations of the JVM, they were all worse. |
@odersky said: |
this is the oldest ticket on this, afaict. there are many others, so anyone wanting to find all of the discussion on this over the years has some link-chasing to do, e.g. to #4152 and many other linked or transitively linked tickets, mailing list discussions, etc |
I would expect that vals of an class/object are either not accessible before their declaration (=> compile-error) or they should already be initialized. (see attached example)
The text was updated successfully, but these errors were encountered: