Closed thomas-bc closed 6 months ago
I looked at the parser implementation. I'm not sure what we can do better, given the parser library that we are using. The parsing logic is here:
It's looking for a formal parameter list followed by a right parenthesis. In your example, when it hits the record
keyword, it's done with the formal parameter list; then it expects a right parenthesis, which isn't there. It reports what it expected, where it expected it, and what's there instead (via the caret ^). If syntax highlighting is on in your editor, you'll see that the highlighted thing is a keyword, in a context where it should be an identifier. This seems reasonably clear.
I think the error message could be friendlier, e.g., "found the keyword record
where )
was expected" or something, but I don't know of any way to get the parser library to generate that error. It just says expected
and what was expected.
"found the keyword
record
where)
was expected"
Would definitely be much much friendlier for users. But also if it's too much trouble, I'm happy to close this issue as wontfix. It's more in the nice-to-have bucket and not worth a lot of time. As you've said syntax highlighting should prevent this from happening in the first place, this was triggered by the introduction of the record keyword.
I think this is something we can change if and when we rewrite the parser. With the current parser combinator library, I don't think it's feasible.
When running a build where a component uses a reserved-keyword such as
send
,record
etc..., the error is really not obvious. e.g. compiling the old version ofSvc/PrmDb/PrmDb.fpp
with FPP v2.1.0aX, the error message isIt takes an awareness of the recent FPP changes to understand what is going on:
record
is now a reserved keyword and should be escaped or renamed.It would be nice to have FPP throw a more meaningful error, or at least a hint, if possible.