gracelang / minigrace

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

definition of object within method broken #266

Closed KimBruce closed 6 years ago

KimBruce commented 6 years ago

Consider the following program:

method m {
    def p = object {}
}

When run, it generates the following error:

Internal compiler error at line 1063 of genjs. NoSuchMethod: no method argumentsDo(_) on defDecNode.new(_,_,_) defdec p.
NoSuchMethod on line 1063 of genjs: no method argumentsDo(_) on defDecNode.new(_,_,_) defdec p.
    in "genjs" (line 1063, column 0)

If you change the def to a var then there is no error. Seems too simple an error to have slipped by this long, but it crashes in both the Pomona and PSU websites. Did I miss something?

apblack commented 6 years ago

Fixed in commit 6d10f1a51

The issue was that def declarations claimed to return an object if their rhs was an object. This is wrong, because a declaration returns done. But this check was used to determine when to create a "scopes" entry for the id on the lhs of the def.