gracelang / minigrace

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

Browser-based IDE discards suggestions for undeclared identifiers #243

Open apblack opened 7 years ago

apblack commented 7 years ago

Code like

method abs(n:Number) → Number { 
    // returns the absolute valye of n
    n.abs
}

print (abs -2)

will produce a static error like this

Syntax error: unknown variable or method 'abs'. This may be a spelling mistake or an attempt to access a variable in another scope.

The message should include the phrase did you mean abs(_)?

apblack commented 5 years ago

The compiler does in fact make suggestions in this case. It says:

abs_issue.grace[7:8-10]: Syntax error: unknown variable or method 'abs'; this may be a spelling mistake, or an attempt to access a variable or method in another scope
  6: 
  7: print (abs -2)
------------^^^

Did you mean:
  7: print (hash

Did you mean:
  7: print (self

Did you mean:
  7: print (List

Did you mean:
  7: print (abs(_)

The problem is that the IDE throws away all but the first line of the error message.

apblack commented 5 years ago

Perhaps the simplest fix is to incorporate the suggestions into the single line error message, when running in the browser.