Open JonathanStarup opened 1 month ago
Hard agree 👍 Thanks for making me aware of it
@JonathanStarup I think this is already better on master
actually. I merged some improvements yesterday. Trying your example I get:
-- Parse Error -------------------------------------------------- main/foo.flix
>> Parse Error: Expected '}' before '.'
3 | case E.tag(x) => x
^
Here
Syntactic Context: OtherExpr.
-- Parse Error -------------------------------------------------- main/foo.flix
>> Parse Error: Expected <declaration> before '('
3 | case E.tag(x) => x
^
Here
Syntactic Context: OtherDecl.
Cool :) thats better yeah. will it be something like hey you have a lowercase constructor
or how ambitious is the parser errors?
Something like that is feasible, and I hope to do that in the next couple of months :) Right now the first error message stems from the tag-pattern parse rule, specifically in the call to name:
private def tagPat()(implicit s: State): Mark.Closed = {
val mark = open()
name(NAME_TAG, allowQualified = true, context = SyntacticContext.Pat.OtherPat)
if (at(TokenKind.ParenL)) {
tuplePat()
}
close(mark, TreeKind.Pattern.Tag)
}
What I would like to to is add another optional argument to name
, expect
and expectAny
to maybe add a contextual tip or something.
name(NAME_TAG, allowQualified = true, context = SyntacticContext.Pat.OtherPat, Some("Constructors use uppercase names"))
Which could land us at:
-- Parse Error -------------------------------------------------- main/foo.flix
>> Expected <Name> before <name>
3 | case E.tag(x) => x
^^^
Here
Hint: Constructors use uppercase names.
Although there is a nice challenge left, with how qualified names can work when we also terminate fixpoint constraints with .
, before that can happen 👍
I'm not sure if this is too minor in the current stage of development, but I would hope this error to be prettier at some point