gracelang / grace-web-editor

A simple editor for Grace
GNU General Public License v3.0
2 stars 8 forks source link

Error messages are truncated at the first newline #66

Open apblack opened 4 years ago

apblack commented 4 years ago

This was originally reported as minigrace issue 116

Note that all of this was discovered using the web editor. Consider the following example:

dialect "staticTypes"

var x:String := {
    print "hi"
}

This is using the incomplete version of the staticTypes dialect, but I don't think that affects this problem. Clearly, x should be a String but is given a Block, so we raise a TypeError. However, what prints is this:

Def TypeError: the expression `{
    in "typechecktest" (line 47, column 2)

The error message gets cut off after the first {. The code that raises this exception is here:

...
DefError.raiseWith("the expression `{value.toGrace(0)}` of type " ++
    "'{vType}' does not satisfy the type of {defd.kind} " ++
    "annotation '{defType}'", value)
...

The problem seems to be that the strings returned by the toGrace method for astNodes often include new line characters (\n). The error message gets cut off right at the first new line character.

apblack commented 4 years ago

The interim fix for this issue is to make sure that error messages don't contain newlines!