mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Merge pull request #2309 from Microsoft/recursiveLetConst
disallow recursive references for block-scoped bindings
This commit is contained in:
10
tests/baselines/reference/for-of55.errors.txt
Normal file
10
tests/baselines/reference/for-of55.errors.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of55.ts(2,15): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/for-ofStatements/for-of55.ts (1 errors) ====
|
||||
let v = [1];
|
||||
for (let v of v) {
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
v;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
=== tests/cases/conformance/es6/for-ofStatements/for-of55.ts ===
|
||||
let v = [1];
|
||||
>v : number[]
|
||||
>[1] : number[]
|
||||
|
||||
for (let v of v) {
|
||||
>v : any
|
||||
>v : any
|
||||
|
||||
v;
|
||||
>v : any
|
||||
}
|
||||
47
tests/baselines/reference/recursiveLetConst.errors.txt
Normal file
47
tests/baselines/reference/recursiveLetConst.errors.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
tests/cases/compiler/recursiveLetConst.ts(2,9): error TS2448: Block-scoped variable 'x' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(3,12): error TS2448: Block-scoped variable 'x1' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(4,11): error TS2448: Block-scoped variable 'y' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(5,14): error TS2448: Block-scoped variable 'y1' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(6,14): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(7,16): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(8,15): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(9,15): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(10,17): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(11,11): error TS2448: Block-scoped variable 'x2' used before its declaration.
|
||||
|
||||
|
||||
==== tests/cases/compiler/recursiveLetConst.ts (10 errors) ====
|
||||
'use strict'
|
||||
let x = x + 1;
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'x' used before its declaration.
|
||||
let [x1] = x1 + 1;
|
||||
~~
|
||||
!!! error TS2448: Block-scoped variable 'x1' used before its declaration.
|
||||
const y = y + 2;
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'y' used before its declaration.
|
||||
const [y1] = y1 + 1;
|
||||
~~
|
||||
!!! error TS2448: Block-scoped variable 'y1' used before its declaration.
|
||||
for (let v = v; ; ) { }
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
for (let [v] = v; ;) { }
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
for (let v in v) { }
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
for (let v of v) { }
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
for (let [v] of v) { }
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
let [x2 = x2] = []
|
||||
~~
|
||||
!!! error TS2448: Block-scoped variable 'x2' used before its declaration.
|
||||
let z0 = () => z0;
|
||||
let z1 = function () { return z1; }
|
||||
let z2 = { f() { return z2;}}
|
||||
42
tests/baselines/reference/recursiveLetConst.js
Normal file
42
tests/baselines/reference/recursiveLetConst.js
Normal file
@@ -0,0 +1,42 @@
|
||||
//// [recursiveLetConst.ts]
|
||||
'use strict'
|
||||
let x = x + 1;
|
||||
let [x1] = x1 + 1;
|
||||
const y = y + 2;
|
||||
const [y1] = y1 + 1;
|
||||
for (let v = v; ; ) { }
|
||||
for (let [v] = v; ;) { }
|
||||
for (let v in v) { }
|
||||
for (let v of v) { }
|
||||
for (let [v] of v) { }
|
||||
let [x2 = x2] = []
|
||||
let z0 = () => z0;
|
||||
let z1 = function () { return z1; }
|
||||
let z2 = { f() { return z2;}}
|
||||
|
||||
//// [recursiveLetConst.js]
|
||||
'use strict';
|
||||
let x = x + 1;
|
||||
let [x1] = x1 + 1;
|
||||
const y = y + 2;
|
||||
const [y1] = y1 + 1;
|
||||
for (let v = v;;) {
|
||||
}
|
||||
for (let [v] = v;;) {
|
||||
}
|
||||
for (let v in v) {
|
||||
}
|
||||
for (let v of v) {
|
||||
}
|
||||
for (let [v] of v) {
|
||||
}
|
||||
let [x2 = x2] = [];
|
||||
let z0 = () => z0;
|
||||
let z1 = function () {
|
||||
return z1;
|
||||
};
|
||||
let z2 = {
|
||||
f() {
|
||||
return z2;
|
||||
}
|
||||
};
|
||||
15
tests/cases/compiler/recursiveLetConst.ts
Normal file
15
tests/cases/compiler/recursiveLetConst.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// @target:es6
|
||||
'use strict'
|
||||
let x = x + 1;
|
||||
let [x1] = x1 + 1;
|
||||
const y = y + 2;
|
||||
const [y1] = y1 + 1;
|
||||
for (let v = v; ; ) { }
|
||||
for (let [v] = v; ;) { }
|
||||
for (let v in v) { }
|
||||
for (let v of v) { }
|
||||
for (let [v] of v) { }
|
||||
let [x2 = x2] = []
|
||||
let z0 = () => z0;
|
||||
let z1 = function () { return z1; }
|
||||
let z2 = { f() { return z2;}}
|
||||
Reference in New Issue
Block a user