gracelang / minigrace

Self-hosting compiler for the Grace programming language
39 stars 22 forks source link

Inheritance through a var or a parameter is not prohibited #250

Open apblack opened 7 years ago

apblack commented 7 years ago
var ooo
ooo := ...
object {
     inherit ooo.new
}

ought to be prohibited regardless of the value assigned to ooo.

apblack commented 7 years ago

The same problem exists with inheriting from a parameter — it's allowed, and should not be.

Here is @KimBruce's example from #251:t presently runs fine, but should be illegal:

def o1 = object {
    class c {
        method m {print "in c"}
    }
}

def o2 = object {   
    class d {
        method n {print "in d"}
    }
}

method build(o') {
    def b = object {
        inherit o'.c
        self.m
        print "in build"
    }
    b.m
}

build(o1)