Fix missing parsingContext restore at return in parseDelimitedList (#48999)

This commit is contained in:
Jake Bailey 2022-05-06 13:36:27 -07:00 committed by GitHub
parent 2ffe6864b1
commit 8d0393d227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 94 additions and 0 deletions

View File

@ -2745,6 +2745,7 @@ namespace ts {
const startPos = scanner.getStartPos();
const result = parseListElement(kind, parseElement);
if (!result) {
parsingContext = saveParsingContext;
return undefined;
}
list.push(result as NonNullable<T>);

View File

@ -0,0 +1,11 @@
tests/cases/compiler/a.js(1,9): error TS1005: ')' expected.
tests/cases/compiler/a.js(1,13): error TS1005: ';' expected.
==== tests/cases/compiler/a.js (2 errors) ====
( y = 1 ; 2 )
~
!!! error TS1005: ')' expected.
~
!!! error TS1005: ';' expected.

View File

@ -0,0 +1,7 @@
//// [a.js]
( y = 1 ; 2 )
//// [a.js]
(y = 1);
2;

View File

@ -0,0 +1,4 @@
=== tests/cases/compiler/a.js ===
( y = 1 ; 2 )
No type information for this code.
No type information for this code.

View File

@ -0,0 +1,8 @@
=== tests/cases/compiler/a.js ===
( y = 1 ; 2 )
>( y = 1 : 1
>y = 1 : 1
>y : any
>1 : 1
>2 : 2

View File

@ -0,0 +1,30 @@
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,10): error TS1109: Expression expected.
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,12): error TS2304: Cannot find name 'x'.
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,16): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,18): error TS2304: Cannot find name 'y'.
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,22): error TS2304: Cannot find name 'z'.
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,27): error TS1109: Expression expected.
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,39): error TS1005: ';' expected.
tests/cases/compiler/parserUnparsedTokenCrash2.ts(2,1): error TS1005: '}' expected.
==== tests/cases/compiler/parserUnparsedTokenCrash2.ts (8 errors) ====
export = } x = ( y = z ==== 'function') {
~
!!! error TS1109: Expression expected.
~
!!! error TS2304: Cannot find name 'x'.
~~~~~~~~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
~
!!! error TS2304: Cannot find name 'y'.
~
!!! error TS2304: Cannot find name 'z'.
~
!!! error TS1109: Expression expected.
~
!!! error TS1005: ';' expected.
!!! error TS1005: '}' expected.
!!! related TS1007 tests/cases/compiler/parserUnparsedTokenCrash2.ts:1:41: The parser expected to find a '}' to match the '{' token here.

View File

@ -0,0 +1,10 @@
//// [parserUnparsedTokenCrash2.ts]
export = } x = ( y = z ==== 'function') {
//// [parserUnparsedTokenCrash2.js]
"use strict";
x = (y = z === ) = 'function';
{
}
module.exports = ;

View File

@ -0,0 +1,4 @@
=== tests/cases/compiler/parserUnparsedTokenCrash2.ts ===
export = } x = ( y = z ==== 'function') {
No type information for this code.
No type information for this code.

View File

@ -0,0 +1,14 @@
=== tests/cases/compiler/parserUnparsedTokenCrash2.ts ===
export = } x = ( y = z ==== 'function') {
> : any
>x = ( y = z ==== 'function' : "function"
>x : any
>( y = z ==== 'function' : "function"
>( y = z === : boolean
>y = z === : boolean
>y : any
>z === : boolean
>z : any
> : any
>'function' : "function"

View File

@ -0,0 +1,4 @@
// @allowJs: true
// @outDir: ./out
// @filename: a.js
( y = 1 ; 2 )

View File

@ -0,0 +1 @@
export = } x = ( y = z ==== 'function') {