gracelang / minigrace

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

if(_)then(_)else(_) not allowed as reciever #316

Open apblack opened 4 years ago

apblack commented 4 years ago

Because if(_)then(_)else(_) is treated by minigrace as a special from, not as a request, there are a number of places where you can't use it.

Specifically, this source code won't compile:

if (aSourceNode.numArgs == 0) then {
    ast.memberNode.new(request, receiver)
} else {
    ast.callNode.new(receiver, aSourceNode.parts)
}.setScope(nodeScope)

As I attempted to write on line 198 of identifierresolution.

The root problem is that minigrace's identifier resolution uses case analysis, and simply does not consider this case. If it used OOP and method dispatch, this would not be an issue.

No re-writing of the receiver is necessary, so nothing has to be done — but the case needs to be recognized.