Skip to content

Weird stack overflow when compiling 4-line code with function, untyped variable, operator and spread operator within cycle #30804

@Veetaha

Description

@Veetaha

TypeScript Version: 3.0.1+ (including [email protected])

Search Terms:

  • Maximum callstack
  • Stack overflow

Code

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

//  bar =  || foo(...bar); // though this is a syntax error, it produces stack overflow also

Expected behavior:
Should compile with error report for spreading undefined and/or leaving bar as implicit any

Actual behavior:
Prints Maximum call stack size exceeded.
Or if you run this script with ts-node:

View ts-node stack trace

image

Playground Link:

This is weird, playground from typescriptlang.com seems to work well, but playground from typescript-play.js.org produces the stack overflow as it does locally in my terminal (Ubuntu 18.04.2 LTS). You may see the error for the second playground in your browser console.

Related Issues:
#25149 To some degree

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions