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

VerifyError with weird circular reference in class def #9270

Open
som-snytt opened this issue Jul 1, 2020 · 3 comments
Open

VerifyError with weird circular reference in class def #9270

som-snytt opened this issue Jul 1, 2020 · 3 comments

Comments

@som-snytt
Copy link
Contributor

som-snytt commented Jul 1, 2020

Minimized code

class C:
  object Foo extends Foo.Bar.Base:
    object Bar:
      class Base

@main def test() =
  val c = new C
  val x = new c.Foo.Bar.Base

Output

$ dotc -d /tmp nested.scala && dotr -classpath /tmp test
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    C$Foo$.<init>(LC;)V @19: invokevirtual
  Reason:
    Type uninitializedThis (current frame, stack[1]) is not assignable to 'C$Foo$'
  Current Frame:
    bci: @19
    flags: { flagThisUninit }
    locals: { uninitializedThis, 'C' }
    stack: { uninitializedThis, uninitializedThis }
  Bytecode:
    0000000: 2bc7 000b bb00 1959 b700 1cbf 2a2b b500
    0000010: 1e2a 2ab6 0022 b700 25b1
  Stackmap Table:
    same_frame(@12)

        at C.Foo(nested.scala:2)
        at nested$package$.test(nested.scala:8)
        at test.main(nested.scala:6)

Expectation

Anything besides a VerifyError.

@smarter smarter removed their assignment Jul 3, 2020
@odersky
Copy link
Contributor

odersky commented Jan 3, 2021

This is still an issue in 2021.

@odersky odersky added this to the 3.0.0-RC1 milestone Jan 3, 2021
@anatoliykmetyuk anatoliykmetyuk modified the milestones: 3.0.0-RC1, 3.0.0-RC2 Feb 11, 2021
@anatoliykmetyuk anatoliykmetyuk removed this from the 3.0.0-RC2 milestone Mar 15, 2021
@xerial
Copy link
Contributor

xerial commented Jul 12, 2021

I also observed a similar compilation error.

ckipp01 added a commit to ckipp01/dotty that referenced this issue May 12, 2023
ckipp01 added a commit to ckipp01/dotty that referenced this issue May 12, 2023
Running this with a too like scala-cli doesn't have any issues, however
this still fails when ran in the test suite.
@SethTisue
Copy link
Member

note that Scala 2.13.12 rejects object Foo extends Foo.Bar.Base { object Bar { class Base } } with "illegal cyclic reference involving object Foo"

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.

6 participants