Only issue matching token errors on non-dupe locations#43460
Only issue matching token errors on non-dupe locations#43460
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.
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.
Yeah, it looks like it was just matching the nearby boolean functions.
| !!! 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.
Why'd we lose this one?
There was a problem hiding this comment.
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.
Can we create separate issue for reporting error like expected , or ] instead.
|
@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 <293473+sandersn@users.noreply.github.com>
Instead of unconditionally retrieving the last error and attaching a related span,
parseErrorAtand friends now return the last error andreturn
falsewhen there is none.Also make one more place use parseExpectedMatchingBrackets that I missed last time.
Previously open questions:
parseErrorAtand friends?Answers:
Fixes comment on #40884.