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
Note the test case from the linked issue fails too:
scala>objectO { val1=2; defx=1 }
// defined object O
scala>O.x
scala.MatchError:2 (of classjava.lang.Integer)
at rs$line$1$O$.<clinit>(rs$line$1:1)
at rs$line$2$.<clinit>(rs$line$2:1)
at rs$line$2.res0(rs$line$2)
@mpilquist I think that test case (which was mine, almost a decade ago) was misconceived. That behavior is actually correct; the def x is a red herring. It boils down to:
scala 2.13.3> object O { val 1 = 2 }
object O
scala 2.13.3> O
scala.MatchError: 2 (of class java.lang.Integer)
The old Scala 2 REPL had two objects, one to wrap user code and a second to pull values out and compose a string to display. The second object was endowed with a reference to the first, to ensure initialization in the absence of members. This is currently done reflectively. I mean currently in Scala 3.
Scala 2 behavior is correct, as per scala/bug#4939
but in Scala 3.0.0-M1:
gitter today:
The text was updated successfully, but these errors were encountered: