hawkw / decaf

like Java, but less so
hawkweisman.me/decaf
Other
18 stars 4 forks source link

Class inheritance cycles incorrectly/improperly detected #48

Closed ArcticLight closed 9 years ago

ArcticLight commented 10 years ago

verifyClassChain is doing much the wrongs; for example

class A {}
class B extends A {}
class C extends B {}

reports an illegal cyclic dependency involving B in class C.

ArcticLight commented 10 years ago

Fixed this in 71a83335b74c8ad65810e7e734984bf5e2f36159 as evidenced by the output

java.lang.IllegalArgumentException: ERROR: Scope attempted to mount itself as parent!
*** Error line 1.
class A { } class B extends A { } class C extends B {} class D extends A {} class Q extends Q {} class R extends Q {}
                                                                                  ^
*** Illegal cyclic class inheritance involving Q on line 1

*** Error line 1.
class A { } class B extends A { } class C extends B {} class D extends A {} class Q extends Q {} class R extends Q {}
                                                                                                       ^
*** Illegal cyclic class inheritance involving R on line 1

Global:  
  D ==> Class: D
  A ==> Class: A
  R ==> Class: R
  C ==> Class: C
  Q ==> Class: Q
  B ==> Class: B
\\
  Class Declaration of A:    
    this ==> Variable of A
  \\
    Class Declaration of B:      
      this ==> Variable of B
    \\
      Class Declaration of C:        
        this ==> Variable of C
    //
    Class Declaration of D:      
      this ==> Variable of D
  //
  Class Declaration of Q:    
    this ==> Variable of Q
  \\
    Class Declaration of R:      
      this ==> Variable of R
  //
//
ArcticLight commented 10 years ago

^ reopen pending discussion

hawkw commented 9 years ago

I don't know, that seems correct to me...? A class shouldn't be able to extend itself?

hawkw commented 9 years ago

I believe this was resolved?