gracelang / minigrace

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

methodTypes not generated properly in gct #328

Open KimBruce opened 4 years ago

KimBruce commented 4 years ago

If you run the following one-line program

var myVar : String is public := "Grace"

and generate the .gct file, it only includes under method types:

 myVar:=(_:String) → Done

when it should also show myVar -> String.

apblack commented 3 years ago

Fixed in 98f4aba. Interestingly, this bug appears to have been present ever since methodTypes were introduced.

Arguably, methodTypes are now unnecessary, since the method signature information ought to be present in the symbol table entry. Currently, the return types are there, but not the parameter types. So myVar has the following symbol table entries in the gct:

 myVar String (var) $scopeEmpty public
 myVar:=(1) String (var) $scopeEmpty public

If the second entry were changed to

myVar:=(_:String)  String (var) $scopeEmpty public

all of the information in methodTypes would be present in the gct scopes.

Note that at present methodTypes are generated by walking the AST, and so do not include entries for methods imported from another module. This is another reason to eliminate methodTypes.

I'll leave this issue open until methodTypes are either eliminated, or made to work.