fix compiler crash (#26209)
This commit is contained in:
parent
3ab7a98ecf
commit
639190d607
6 changed files with 48 additions and 18 deletions
|
@ -23958,13 +23958,13 @@ namespace ts {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
addDiagnostic(bindingPattern, kind, bindingElements.length === 1
|
addDiagnostic(bindingPattern, kind, bindingElements.length === 1
|
||||||
? createDiagnosticForNode(bindingPattern, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(cast(first(bindingElements).name, isIdentifier)))
|
? createDiagnosticForNode(bindingPattern, Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(first(bindingElements).name))
|
||||||
: createDiagnosticForNode(bindingPattern, Diagnostics.All_destructured_elements_are_unused));
|
: createDiagnosticForNode(bindingPattern, Diagnostics.All_destructured_elements_are_unused));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (const e of bindingElements) {
|
for (const e of bindingElements) {
|
||||||
addDiagnostic(e, kind, createDiagnosticForNode(e, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(cast(e.name, isIdentifier))));
|
addDiagnostic(e, kind, createDiagnosticForNode(e, Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(e.name)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -23976,7 +23976,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (const decl of declarations) {
|
for (const decl of declarations) {
|
||||||
addDiagnostic(decl, UnusedKind.Local, createDiagnosticForNode(decl, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(cast(decl.name, isIdentifier))));
|
addDiagnostic(decl, UnusedKind.Local, createDiagnosticForNode(decl, Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,14 +4,11 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(15,5): error TS6133: 'farrow'
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(15,15): error TS6133: 'a' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(15,15): error TS6133: 'a' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(18,7): error TS6196: 'C' is declared but never used.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(18,7): error TS6196: 'C' is declared but never used.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(20,12): error TS6133: 'a' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(20,12): error TS6133: 'a' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(23,11): error TS6133: 'v' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(23,11): error TS6133: 'v' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(27,5): error TS6133: 'E' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(27,5): error TS6133: 'E' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(29,12): error TS6133: 'a' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(29,12): error TS6133: 'a' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(32,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(32,11): error TS6133: 'v' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(32,11): error TS6133: 'v' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(38,12): error TS6133: 'a' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(38,12): error TS6133: 'a' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(41,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(41,11): error TS6133: 'v' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(41,11): error TS6133: 'v' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(48,10): error TS6133: 'i' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(48,10): error TS6133: 'i' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(52,10): error TS6133: 'i' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(52,10): error TS6133: 'i' is declared but its value is never read.
|
||||||
|
@ -22,9 +19,13 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(71,11): error TS6133: 'c' is d
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(74,11): error TS6133: 'c' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(74,11): error TS6133: 'c' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(79,11): error TS6133: 'N' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(79,11): error TS6133: 'N' is declared but its value is never read.
|
||||||
tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is declared but its value is never read.
|
tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is declared but its value is never read.
|
||||||
|
tests/cases/compiler/unusedLocalsAndParameters.ts(83,13): error TS2304: Cannot find name 'y'.
|
||||||
|
tests/cases/compiler/unusedLocalsAndParameters.ts(83,14): error TS1005: ',' expected.
|
||||||
|
tests/cases/compiler/unusedLocalsAndParameters.ts(84,6): error TS1005: ',' expected.
|
||||||
|
tests/cases/compiler/unusedLocalsAndParameters.ts(85,1): error TS1109: Expression expected.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/unusedLocalsAndParameters.ts (24 errors) ====
|
==== tests/cases/compiler/unusedLocalsAndParameters.ts (25 errors) ====
|
||||||
export { };
|
export { };
|
||||||
|
|
||||||
// function declaration paramter
|
// function declaration paramter
|
||||||
|
@ -60,8 +61,6 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de
|
||||||
}
|
}
|
||||||
// Accessor declaration paramter
|
// Accessor declaration paramter
|
||||||
set x(v: number) {
|
set x(v: number) {
|
||||||
~
|
|
||||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
||||||
~
|
~
|
||||||
!!! error TS6133: 'v' is declared but its value is never read.
|
!!! error TS6133: 'v' is declared but its value is never read.
|
||||||
}
|
}
|
||||||
|
@ -77,8 +76,6 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de
|
||||||
}
|
}
|
||||||
// Accessor declaration paramter
|
// Accessor declaration paramter
|
||||||
set x(v: number) {
|
set x(v: number) {
|
||||||
~
|
|
||||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
||||||
~
|
~
|
||||||
!!! error TS6133: 'v' is declared but its value is never read.
|
!!! error TS6133: 'v' is declared but its value is never read.
|
||||||
}
|
}
|
||||||
|
@ -92,8 +89,6 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de
|
||||||
},
|
},
|
||||||
// Accessor declaration paramter
|
// Accessor declaration paramter
|
||||||
set x(v: number) {
|
set x(v: number) {
|
||||||
~
|
|
||||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
||||||
~
|
~
|
||||||
!!! error TS6133: 'v' is declared but its value is never read.
|
!!! error TS6133: 'v' is declared but its value is never read.
|
||||||
}
|
}
|
||||||
|
@ -155,4 +150,15 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de
|
||||||
!!! error TS6133: 'x' is declared but its value is never read.
|
!!! error TS6133: 'x' is declared but its value is never read.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let x: y) {
|
||||||
|
~
|
||||||
|
!!! error TS2304: Cannot find name 'y'.
|
||||||
|
~
|
||||||
|
!!! error TS1005: ',' expected.
|
||||||
|
z(x);
|
||||||
|
~
|
||||||
|
!!! error TS1005: ',' expected.
|
||||||
|
}
|
||||||
|
~
|
||||||
|
!!! error TS1109: Expression expected.
|
||||||
|
|
|
@ -81,7 +81,10 @@ namespace N {
|
||||||
var x;
|
var x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let x: y) {
|
||||||
|
z(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//// [unusedLocalsAndParameters.js]
|
//// [unusedLocalsAndParameters.js]
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -166,3 +169,5 @@ var N;
|
||||||
(function (N) {
|
(function (N) {
|
||||||
var x;
|
var x;
|
||||||
})(N || (N = {}));
|
})(N || (N = {}));
|
||||||
|
for (var x = void 0, z = (void 0).z; (x); )
|
||||||
|
;
|
||||||
|
|
|
@ -131,4 +131,11 @@ namespace N {
|
||||||
>x : Symbol(x, Decl(unusedLocalsAndParameters.ts, 79, 7))
|
>x : Symbol(x, Decl(unusedLocalsAndParameters.ts, 79, 7))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let x: y) {
|
||||||
|
>x : Symbol(x, Decl(unusedLocalsAndParameters.ts, 82, 8))
|
||||||
|
|
||||||
|
z(x);
|
||||||
|
>z : Symbol(z, Decl(unusedLocalsAndParameters.ts, 82, 16))
|
||||||
|
>x : Symbol(x, Decl(unusedLocalsAndParameters.ts, 82, 8))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,4 +152,14 @@ namespace N {
|
||||||
>x : any
|
>x : any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let x: y) {
|
||||||
|
>x : any
|
||||||
|
|
||||||
|
z(x);
|
||||||
|
>z : any
|
||||||
|
>(x) : any
|
||||||
|
>x : any
|
||||||
|
}
|
||||||
|
> : any
|
||||||
|
> : any
|
||||||
|
|
||||||
|
|
|
@ -83,4 +83,6 @@ namespace N {
|
||||||
var x;
|
var x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let x: y) {
|
||||||
|
z(x);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue