Uh oh!
There was an error while loading. Please reload this page.
Make the parser’s ‘expected <foo>, found <bar>’ errors more accurate - #19494
Conversation
brson
commented
Dec 3, 2014
This looks pretty clever and useful. Is it incorrect to ever compare equality of |
ftxqxd
commented
Dec 3, 2014
No, it’s not incorrect to compare That said, I think you’re right in that it’s very easy for someone modifying the parser in the future to write |
brson
commented
Dec 3, 2014
@P1start I'm not sure whether it's necessary. The potential bug is relatively minor: that the error fails to suggest a possible token. I'll leave it to your judgement to decide whether such defensive programming is warranted here. |
As an example of what this changes, the following code: let x: [int ..4]; Currently spits out ‘expected `]`, found `..`’. However, a comma would also be valid there, as would a number of other tokens. This change adjusts the parser to produce more accurate errors, so that that example now produces ‘expected one of `(`, `+`, `,`, `::`, or `]`, found `..`’.
ftxqxd
commented
Dec 4, 2014
I decided not to prevent I did end up removing r? @brson |
chore: Remove unnecessary `Arc` clones
As an example of what this changes, the following code:
Currently spits out ‘expected
], found..’. However, a comma would also be valid there, as would a number of other tokens. This change adjusts the parser to produce more accurate errors, so that that example now produces ‘expected one of(,+,,,::, or], found..’.(Thanks to cramer on IRC for pointing out this problem with diagnostics.)