Skip to content

Commit 8d0393d

Browse files
authored
Fix missing parsingContext restore at return in parseDelimitedList (microsoft#48999)
1 parent 2ffe686 commit 8d0393d

11 files changed

+94
-0
lines changed

src/compiler/parser.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2745,6 +2745,7 @@ namespace ts {
27452745
const startPos = scanner.getStartPos();
27462746
const result = parseListElement(kind, parseElement);
27472747
if (!result) {
2748+
parsingContext = saveParsingContext;
27482749
return undefined;
27492750
}
27502751
list.push(result as NonNullable<T>);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
tests/cases/compiler/a.js(1,9): error TS1005: ')' expected.
2+
tests/cases/compiler/a.js(1,13): error TS1005: ';' expected.
3+
4+
5+
==== tests/cases/compiler/a.js (2 errors) ====
6+
( y = 1 ; 2 )
7+
~
8+
!!! error TS1005: ')' expected.
9+
~
10+
!!! error TS1005: ';' expected.
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [a.js]
2+
( y = 1 ; 2 )
3+
4+
5+
//// [a.js]
6+
(y = 1);
7+
2;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== tests/cases/compiler/a.js ===
2+
( y = 1 ; 2 )
3+
No type information for this code.
4+
No type information for this code.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/compiler/a.js ===
2+
( y = 1 ; 2 )
3+
>( y = 1 : 1
4+
>y = 1 : 1
5+
>y : any
6+
>1 : 1
7+
>2 : 2
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,10): error TS1109: Expression expected.
2+
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,12): error TS2304: Cannot find name 'x'.
3+
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.
4+
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,18): error TS2304: Cannot find name 'y'.
5+
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,22): error TS2304: Cannot find name 'z'.
6+
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,27): error TS1109: Expression expected.
7+
tests/cases/compiler/parserUnparsedTokenCrash2.ts(1,39): error TS1005: ';' expected.
8+
tests/cases/compiler/parserUnparsedTokenCrash2.ts(2,1): error TS1005: '}' expected.
9+
10+
11+
==== tests/cases/compiler/parserUnparsedTokenCrash2.ts (8 errors) ====
12+
export = } x = ( y = z ==== 'function') {
13+
~
14+
!!! error TS1109: Expression expected.
15+
~
16+
!!! error TS2304: Cannot find name 'x'.
17+
~~~~~~~~~~~
18+
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
19+
~
20+
!!! error TS2304: Cannot find name 'y'.
21+
~
22+
!!! error TS2304: Cannot find name 'z'.
23+
~
24+
!!! error TS1109: Expression expected.
25+
~
26+
!!! error TS1005: ';' expected.
27+
28+
29+
!!! error TS1005: '}' expected.
30+
!!! related TS1007 tests/cases/compiler/parserUnparsedTokenCrash2.ts:1:41: The parser expected to find a '}' to match the '{' token here.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [parserUnparsedTokenCrash2.ts]
2+
export = } x = ( y = z ==== 'function') {
3+
4+
5+
//// [parserUnparsedTokenCrash2.js]
6+
"use strict";
7+
x = (y = z === ) = 'function';
8+
{
9+
}
10+
module.exports = ;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== tests/cases/compiler/parserUnparsedTokenCrash2.ts ===
2+
export = } x = ( y = z ==== 'function') {
3+
No type information for this code.
4+
No type information for this code.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/compiler/parserUnparsedTokenCrash2.ts ===
2+
export = } x = ( y = z ==== 'function') {
3+
> : any
4+
>x = ( y = z ==== 'function' : "function"
5+
>x : any
6+
>( y = z ==== 'function' : "function"
7+
>( y = z === : boolean
8+
>y = z === : boolean
9+
>y : any
10+
>z === : boolean
11+
>z : any
12+
> : any
13+
>'function' : "function"
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @allowJs: true
2+
// @outDir: ./out
3+
// @filename: a.js
4+
( y = 1 ; 2 )
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export = } x = ( y = z ==== 'function') {

0 commit comments

Comments
 (0)