Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don’t use checkExpressionCached when checking spread element inside a…
… loop
- Loading branch information
1 parent
48f0380
commit 89497fc
Showing
6 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,16): error TS2556: Expected 0 arguments, but got 1 or more. | ||
tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,19): error TS2461: Type 'number' is not an array type. | ||
tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,19): error TS2461: Type 'undefined' is not an array type. | ||
|
||
|
||
==== tests/cases/compiler/noImplicitAnyLoopCrash.ts (3 errors) ==== | ||
let foo = () => {}; | ||
let bar; | ||
while (1) { | ||
bar = ~foo(...bar); | ||
~~~~~~ | ||
!!! error TS2556: Expected 0 arguments, but got 1 or more. | ||
~~~ | ||
!!! error TS2461: Type 'number' is not an array type. | ||
~~~ | ||
!!! error TS2461: Type 'undefined' is not an array type. | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//// [noImplicitAnyLoopCrash.ts] | ||
let foo = () => {}; | ||
let bar; | ||
while (1) { | ||
bar = ~foo(...bar); | ||
} | ||
|
||
|
||
//// [noImplicitAnyLoopCrash.js] | ||
var foo = function () { }; | ||
var bar; | ||
while (1) { | ||
bar = ~foo.apply(void 0, bar); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
=== tests/cases/compiler/noImplicitAnyLoopCrash.ts === | ||
let foo = () => {}; | ||
>foo : Symbol(foo, Decl(noImplicitAnyLoopCrash.ts, 0, 3)) | ||
|
||
let bar; | ||
>bar : Symbol(bar, Decl(noImplicitAnyLoopCrash.ts, 1, 3)) | ||
|
||
while (1) { | ||
bar = ~foo(...bar); | ||
>bar : Symbol(bar, Decl(noImplicitAnyLoopCrash.ts, 1, 3)) | ||
>foo : Symbol(foo, Decl(noImplicitAnyLoopCrash.ts, 0, 3)) | ||
>bar : Symbol(bar, Decl(noImplicitAnyLoopCrash.ts, 1, 3)) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
=== tests/cases/compiler/noImplicitAnyLoopCrash.ts === | ||
let foo = () => {}; | ||
>foo : () => void | ||
>() => {} : () => void | ||
|
||
let bar; | ||
>bar : any | ||
|
||
while (1) { | ||
>1 : 1 | ||
|
||
bar = ~foo(...bar); | ||
>bar = ~foo(...bar) : number | ||
>bar : any | ||
>~foo(...bar) : number | ||
>foo(...bar) : void | ||
>foo : () => void | ||
>...bar : any | ||
>bar : number | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// @noImplicitAny: true | ||
let foo = () => {}; // if you remove or change foo definition to not a function, bug disappears | ||
let bar; // if you add type annotation here, bug disappears | ||
while (1) // if you remove while, bug disappears | ||
bar = ~foo(...bar); // if you remove unary or spread operator, bug disappears | ||
let foo = () => {}; | ||
let bar; | ||
while (1) { | ||
bar = ~foo(...bar); | ||
} |