You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--Warning:--------------------------------------------------------------------4|valred=Red|^^^|Access uninitialized field value Red. Callingtrace:
|├──enumColor: [ rs$line$1:1 ]
|│^|├──caseRed, Green, Blue [ rs$line$1:2 ]
|│^|├──enumColor: [ rs$line$1:1 ]
|│^|└──valred=Red [ rs$line$1:4 ]
|^^^
this isn't really possible to fix, it is exactly like doing this cyclic initialisation:
classFoo:valred=Foo.Red// constructor sets to value of uninitialised fieldobjectFoo:valRed=Foo() // can't store field until constructor is finished
println(Foo.Red.red)
this isn't really possible to fix, it is exactly like doing this cyclic initialisation:
classFoo:valred=Foo.Red// constructor sets to value of uninitialised fieldobjectFoo:valRed=Foo() // can't store field until constructor is finished
println(Foo.Red.red)
@bishabosha Hmm... If it is indeed a won'tfix, then we should have something better than a warning with a private flag such as -Ysafe-init-global, I think...
Could we just always warn, or even throw an error in this case?
cc @dwijnand@odersky@kasiaMarek
Compiler version
3.5.2
Minimized code
Output
null
Expectation
Value should be initialized and print
Color.Red
The text was updated successfully, but these errors were encountered: