Repository navigation
parser: report errors inside argument lists at their position - #84
Merged
Merged
Conversation
The arguments of a call and an indexer were labeled with As, which
discards the diagnostics from inside the labeled parser. A list stops
before a broken argument, so the error pointed at the comma before it
or at the start of the list rather than where an expression is missing:
"test".ToString(1,) (1:18) Expected ')'
Math.Max(1, (2 + )) (1:11) Expected ')'
"test"[(] (1:8) Expected expression
Remove both labels, so the error points where the expression is
missing, as in C#, and lists the tokens that can start an expression,
as for 1 +. An empty indexer, as in "test"[], gets the same list
instead of "Expected expression", and an unfinished list, as in
"test"[0, lists the operators, ',' and ']', as 1 + (2 * 3 does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an argument of a call or an indexer was broken, the error pointed at the comma before it or at the start of the list instead of where an expression is missing:
"test".ToString(1,)(1:18) Expected ')'(1:19) Expected [!+\-~], …Math.Max(1, (2 + ))(1:11) Expected ')'(1:18) Expected [!+\-~], …"test"[(](1:8) Expected expression(1:9) Expected [!+\-~], …The argument lists were labeled with
As, which discards the diagnostics from inside the list. This PR removes both labels, so the position matches the C# compiler. The message now lists the tokens that can start an expression, as for1 +. This also applies to an empty indexer, as in"test"[], which has reportedExpected expressionsince #83.