Skip to content

Unbalanced curly brackets crashes the compiler #18216

Description

@pelotom

TypeScript Version: 2.5.2

If you try to compile source with unbalanced curlies, e.g.

if (true) {

it hard-crashes the compiler with:

/Users/tom/code/console/node_modules/typescript/lib/tsc.js:2062
            throw e;
            ^

Error: Debug Failure. False expression.
    at computePositionOfLineAndCharacter (/Users/tom/code/console/node_modules/typescript/lib/tsc.js:3752:22)
    at Object.getPositionOfLineAndCharacter (/Users/tom/code/console/node_modules/typescript/lib/tsc.js:3742:16)
    at Object.formatDiagnosticsWithColorAndContext (/Users/tom/code/console/node_modules/typescript/lib/tsc.js:55574:40)
    at reportDiagnosticWithColorAndContext (/Users/tom/code/console/node_modules/typescript/lib/tsc.js:58771:25)
    at reportDiagnostic (/Users/tom/code/console/node_modules/typescript/lib/tsc.js:58733:9)
    at reportDiagnostics (/Users/tom/code/console/node_modules/typescript/lib/tsc.js:58738:13)
    at compileProgram (/Users/tom/code/console/node_modules/typescript/lib/tsc.js:59099:13)
    at compile (/Users/tom/code/console/node_modules/typescript/lib/tsc.js:59051:26)
    at performCompilation (/Users/tom/code/console/node_modules/typescript/lib/tsc.js:58940:33)
    at Timeout.recompile [as _onTimeout] (/Users/tom/code/console/node_modules/typescript/lib/tsc.js:59039:13)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)

This is a regression from 2.4.2, where it would instead gracefully report

src/example.ts(105,1): error TS1005: '}' expected.

This is particularly bothersome because it crashes out of --watch mode.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueNeeds More InfoThe issue still hasn't been fully clarified

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions