Currently, when a users writes some invalid syntax, they get a message saying ERROR: syntax: .... I think it might be helpful if we distinguished between whether the parser complained or the lowering complained. Consider these two situations:
julia> f(::)
ERROR: syntax: unexpected ")"
Stacktrace:
[1] top-level scope at none:1
julia> f(::T)
ERROR: syntax: invalid "::" syntax around REPL[19]:1
Stacktrace:
[1] top-level scope at REPL[19]:1
To a naive eye, both of these might look like errors thrown by the parser and hence neither expression would be valid e.g. in a macro, but it turns out that the second error was actually produced during lowering, not parsing:
julia> :(f(::))
ERROR: syntax: unexpected ")"
Stacktrace:
[1] top-level scope at none:1
julia> :(f(::A))
:(f(::A))
I suppose an expert eye might have noticed that the second expression said syntax around REPL[19]:1 and this suggests that the expression was in the lowering phase, but I think it might be good if this one instead threw say a LoweringError that suggests that the problem was with lowering rather than parsing.
This is important for figuring out what sort of syntax can be used in macros.
OTOH, this is a distinction that isn't important for people writing the code and may cause additional confusion.
I'm not sure that highlighting this in the standard error reporting is the right way forward — I suspect the average user is very unlikely to appreciate the difference, and certainly new users are going to be confused.
Still, I agree there's something bothersome about the reporting of lowering errors vs syntax errors and I think we can do better by tweaking something appropriately. But I'm not quite sure what.
Most helpful comment
OTOH, this is a distinction that isn't important for people writing the code and may cause additional confusion.