pyret-lang
pyret-lang copied to clipboard
include gives poor error message for `reactor`
If you type include reactor instead of include reactors, it would be nice to get an error that says "I can't find a library of that name" (as you do if you try to include foo). Right now this produces a syntax error. While that makes sense if you understand parsing, it also seems like an unfortunate response in a language where we have a library named reactors…
That's not really possible in any plausible engineering sort of way. reactor is a token recognized by the lexer, so this will intrinsically produce a syntax error. You'd have to extend the grammar of the language with a bogus: INCLUDE REACTOR production, and add that bogus production into the valid productions, and then try to filter it back out much later in the compiler somehow, and that seems very hacky and brittle to me, and unlikely to be easily maintained.
Note that we already do syntax-highlight include reactor as bolded, where all the other includes aren't bold, so there does exist some signal for why this is happening. It's subtle, granted.