Skip to content

Commit 40ac03c

Browse files
committed
Add nested switch block testcase
1 parent 309dfa3 commit 40ac03c

File tree

5 files changed

+83
-3
lines changed

5 files changed

+83
-3
lines changed

tests/baselines/reference/switchCaseTdz.errors.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ tests/cases/compiler/switchCaseTdz.ts(46,13): error TS2837: Variable 'z' is decl
1919
tests/cases/compiler/switchCaseTdz.ts(50,13): error TS2837: Variable 'x' is declared in a prior case block.
2020
tests/cases/compiler/switchCaseTdz.ts(51,13): error TS2837: Variable 'y' is declared in a prior case block.
2121
tests/cases/compiler/switchCaseTdz.ts(52,13): error TS2837: Variable 'z' is declared in a prior case block.
22+
tests/cases/compiler/switchCaseTdz.ts(64,17): error TS2837: Variable 'x' is declared in a prior case block.
2223

2324

24-
==== tests/cases/compiler/switchCaseTdz.ts (21 errors) ====
25+
==== tests/cases/compiler/switchCaseTdz.ts (22 errors) ====
2526
switch (1 + 1) {
2627
case -1:
2728
x;
@@ -123,4 +124,15 @@ tests/cases/compiler/switchCaseTdz.ts(52,13): error TS2837: Variable 'z' is decl
123124
}
124125

125126
}
126-
127+
128+
switch(2 + 2) {
129+
case 0:
130+
let x = 1;
131+
switch(x + x) {
132+
case 2:
133+
// Legal
134+
x;
135+
~
136+
!!! error TS2837: Variable 'x' is declared in a prior case block.
137+
}
138+
}

tests/baselines/reference/switchCaseTdz.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,16 @@ switch (1 + 1) {
5555
}
5656

5757
}
58-
58+
59+
switch(2 + 2) {
60+
case 0:
61+
let x = 1;
62+
switch(x + x) {
63+
case 2:
64+
// Legal
65+
x;
66+
}
67+
}
5968

6069
//// [switchCaseTdz.js]
6170
switch (1 + 1) {
@@ -109,3 +118,12 @@ switch (1 + 1) {
109118
ok;
110119
};
111120
}
121+
switch (2 + 2) {
122+
case 0:
123+
var x = 1;
124+
switch (x + x) {
125+
case 2:
126+
// Legal
127+
x;
128+
}
129+
}

tests/baselines/reference/switchCaseTdz.symbols

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,18 @@ switch (1 + 1) {
123123

124124
}
125125

126+
switch(2 + 2) {
127+
case 0:
128+
let x = 1;
129+
>x : Symbol(x, Decl(switchCaseTdz.ts, 59, 11))
130+
131+
switch(x + x) {
132+
>x : Symbol(x, Decl(switchCaseTdz.ts, 59, 11))
133+
>x : Symbol(x, Decl(switchCaseTdz.ts, 59, 11))
134+
135+
case 2:
136+
// Legal
137+
x;
138+
>x : Symbol(x, Decl(switchCaseTdz.ts, 59, 11))
139+
}
140+
}

tests/baselines/reference/switchCaseTdz.types

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,28 @@ switch (1 + 1) {
155155

156156
}
157157

158+
switch(2 + 2) {
159+
>2 + 2 : number
160+
>2 : 2
161+
>2 : 2
162+
163+
case 0:
164+
>0 : 0
165+
166+
let x = 1;
167+
>x : number
168+
>1 : 1
169+
170+
switch(x + x) {
171+
>x + x : number
172+
>x : number
173+
>x : number
174+
175+
case 2:
176+
>2 : 2
177+
178+
// Legal
179+
x;
180+
>x : number
181+
}
182+
}

tests/cases/compiler/switchCaseTdz.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,13 @@ switch (1 + 1) {
5454
}
5555

5656
}
57+
58+
switch(2 + 2) {
59+
case 0:
60+
let x = 1;
61+
switch(x + x) {
62+
case 2:
63+
// Legal
64+
x;
65+
}
66+
}

0 commit comments

Comments
 (0)