-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Only issue matching token errors on non-dupe locations #43460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Intead of unconditionally retrieving the last error and attaching a related span, `parseErrorAt` and friends now return the last error and return `false` when there is none. Also make one more place use parseExpectedMatchingBrackets that I missed last time.
@typescript-bot perf test this |
Heya @sandersn, I've started to run the perf test suite on this PR at c141447. You can monitor the build here. Update: The results are in! |
Re 2: it reads less strangely to use undefined, so I'm going to do that. |
@typescript-bot perf test this |
Heya @sandersn, I've started to run the perf test suite on this PR at 435c99d. You can monitor the build here. Update: The results are in! |
@sandersn Here they are:Comparison Report - master..43460
System
Hosts
Scenarios
Developer Information: |
First perf run shows no difference |
src/compiler/parser.ts
Outdated
return false; | ||
if (token() === closeKind) { | ||
nextToken(); | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like no part of the parser consumes the return value, so you can make this void
-returning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it looks like it was just matching the nearby boolean functions.
@@ -39,7 +39,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( | |||
!!! error TS2322: Type 'string' is not assignable to type 'number'. | |||
~ | |||
!!! error TS1005: ',' expected. | |||
!!! related TS1007 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:7:4: The parser expected to find a ']' to match the '[' token here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why'd we lose this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both ,
and ]
were expected, but ,
got there first, so the ]
error didn't get issued. With return value in hand, the code now skips issuing a []
related span on a ,
error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create separate issue for reporting error like expected ,
or ]
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea: #43467
@sandersn Here they are:Comparison Report - master..43460
System
Hosts
Scenarios
Developer Information: |
Thank you! |
…soft#43460)" This reverts commit 76a2ae3.
* Revert "Only issue matching token errors on non-dupe locations (microsoft#43460)" This reverts commit 76a2ae3. * Revert "Adding Diagnostic message for missing ']' and ')' in Array literal and conditional statements (microsoft#40884)" This reverts commit 555ef73. * re-add clobbered merge lines
This reverts commit 5770434.
…brackets (#44158) * Revert "Revert #43460 and #40884 (#44175)" This reverts commit 5770434. * fix missing opening brace match error * refactor parseExpectedMatchingBrackets * use getNodePos * accept baselines * delete mistakenly added files * Revert getNodePos addition Co-authored-by: Nathan Shively-Sanders <[email protected]>
Instead of unconditionally retrieving the last error and attaching a related span,
parseErrorAt
and friends now return the last error andreturn
false
when there is none.Also make one more place use parseExpectedMatchingBrackets that I missed last time.
Previously open questions:
parseErrorAt
and friends?Answers:
Fixes comment on #40884.