Open e-kayrakli opened 2 months ago
I am not sure how parser parsed that line, but this could be a syntax error as I can't come up with something with [] legally appearing right before dmapped.
It's not surprising to me that it parsed w.r.t. dmapped
's LHS, as the production for dmapped
is simply expr TDMAPPED expr
so that dmapped can be applied to a literal, variable, field access, procedure call (returning a domain), etc. without getting too specific.
The part that's unclear to me me is that I'd expect the parser to treat this as a square-bracket loop expression (as the error suggests it did), and for the production for the square bracket expression to be something like TLSBR whatever TRSBR expr
(i.e., a bracket_loop_expr_base
)—yet dmapped new…
shouldn't be a legal expression. So I'm not sure what path the statement is taking through the parser to be interpreted as a loop expression…
I forget that we support [1]
without a dangling comma as an array literal (was that something I fought against? :D). I was thinking that [Space]
couldn't be an expression, but it could be an array literal.
Aha, that's what I was overlooking as well… I wonder how much less parsing pain for square brackets we'd have if we removed that case…
Perhaps we should add a post-parse-check for this case rather than trying to make it a syntax error.
Consider the following illegal code:
Here, in
Dom
's initialization, I used[Space]
by mistake instead of justSpace
. The error message is unhelpful:I am not sure how parser parsed that line, but this could be a syntax error as I can't come up with something with
[]
legally appearing right beforedmapped
.