joe-greenawalt / skulpt

Automatically exported from code.google.com/p/skulpt
Other
0 stars 0 forks source link

Diamond/shared ancestor inheritance incorrect #113

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Code you're trying to run:

class ClassA:
    def p(self):
        print "A"

class ClassB (ClassA):
    pass

class ClassC (ClassA):
    def p(self):
        print "C"

class ClassBC (ClassB, ClassC):
    pass

b=ClassB()
b.p()
bc=ClassBC()
bc.p()

What does "real" Python output (2.6.6 and 2.7.3)?

A
A

What does Skulpt output?

A
C

Please provide any additional information.

The correct search order should be ClassBC, Class B, ClassA, ClassC (then I 
guess ClassA again?) It seems to be specific to shared ancestors, if there are 
no shared ancestors then the method search recurses properly. If ClassC does 
not inherit from ClassA, then the output matches real python's.

Wild speculation: the wrong ClassA is being removed from the search list for 
being redundant?  If I remove the "p" function from ClassC, ClassA's function 
is called which shows that it IS being searched, just in the wrong order.

Original issue reported on code.google.com by Fred.Kni...@gmail.com on 16 Dec 2012 at 6:15