TypeScript Server Error (3.8.0-beta) Debug Failure. False expression.

Created on 23 Jan 2020  路  4Comments  路  Source: microsoft/TypeScript

In VSCode:
https://github.com/microsoft/vscode/blob/330d9a77eb17a8b523904734ee297f0fb2b649fa/src/vs/workbench/contrib/search/browser/searchEditor.ts#L93-L121

Attempt to extract selected region (lines 93 to 121) to new method. Observe error:

<semantic> TypeScript Server Error (3.8.0-beta)
Debug Failure. False expression.
Error: Debug Failure. False expression.
    at getPos (tsserver.js:122075:22)
    at assignPositionsToNode (tsserver.js:122816:27)
    at visitNode (tsserver.js:72254:23)
    at Object.visitEachChild (tsserver.js:72471:117)
    at assignPositionsToNode (tsserver.js:122813:30)
    at visitNode (tsserver.js:72254:23)
    at Object.visitEachChild (tsserver.js:72481:53)
    at assignPositionsToNode (tsserver.js:122813:30)
    at visitNode (tsserver.js:72254:23)
    at Object.visitEachChild (tsserver.js:72509:46)
    at assignPositionsToNode (tsserver.js:122813:30)
    at visitNode (tsserver.js:72254:23)
    at Object.visitEachChild (tsserver.js:72567:224)
    at assignPositionsToNode (tsserver.js:122813:30)
    at Object.visitNodes (tsserver.js:72305:48)
    at assignPositionsToNodeArray (tsserver.js:122821:30)
    at Object.visitEachChild (tsserver.js:72569:63)
    at assignPositionsToNode (tsserver.js:122813:30)
    at visitNode (tsserver.js:72254:23)
    at Object.visitEachChild (tsserver.js:72535:111)
    at assignPositionsToNode (tsserver.js:122813:30)
    at Object.visitNodes (tsserver.js:72305:48)
    at assignPositionsToNodeArray (tsserver.js:122821:30)
    at Object.visitEachChild (tsserver.js:72533:45)
    at assignPositionsToNode (tsserver.js:122813:30)
    at visitNode (tsserver.js:72254:23)
    at Object.visitEachChild (tsserver.js:72539:96)
    at assignPositionsToNode (tsserver.js:122813:30)
    at Object.visitNodes (tsserver.js:72305:48)
    at assignPositionsToNodeArray (tsserver.js:122821:30)
    at Object.visitEachChild (tsserver.js:72533:45)
    at assignPositionsToNode (tsserver.js:122813:30)
    at visitNode (tsserver.js:72254:23)
    at Object.visitEachChild (tsserver.js:72539:96)
    at assignPositionsToNode (tsserver.js:122813:30)
    at Object.visitNodes (tsserver.js:72305:48)
    at assignPositionsToNodeArray (tsserver.js:122821:30)
    at Object.visitEachChild (tsserver.js:72533:45)
    at assignPositionsToNode (tsserver.js:122813:30)
    at visitNode (tsserver.js:72254:23)
    at visitFunctionBody (tsserver.js:72358:23)
    at Object.visitEachChild (tsserver.js:72495:358)
    at assignPositionsToNode (tsserver.js:122813:30)
    at Object.visitNodes (tsserver.js:72305:48)
    at assignPositionsToNodeArray (tsserver.js:122821:30)
    at Object.visitEachChild (tsserver.js:72483:156)
    at assignPositionsToNode (tsserver.js:122813:30)
    at visitNode (tsserver.js:72254:23)
    at Object.visitEachChild (tsserver.js:72537:59)
    at assignPositionsToNode (tsserver.js:122813:30)
    at Object.visitNodes (tsserver.js:72305:48)
    at assignPositionsToNodeArray (tsserver.js:122821:30)
    at Object.visitEachChild (tsserver.js:72533:45)
    at assignPositionsToNode (tsserver.js:122813:30)
    at visitNode (tsserver.js:72254:23)
    at visitFunctionBody (tsserver.js:72358:23)
    at Object.visitEachChild (tsserver.js:72403:510)
    at assignPositionsToNode (tsserver.js:122813:30)
    at getNonformattedText (tsserver.js:122797:56)
    at getFormattedTextOfNode (tsserver.js:122778:26)
    at format (tsserver.js:122761:52)
    at computeNewText (tsserver.js:122764:23)
    at tsserver.js:122734:89
    at Array.map (<anonymous>)
    at tsserver.js:122733:50
    at Array.map (<anonymous>)
    at Object.getTextChangesFromChanges (tsserver.js:122719:86)
    at ChangeTracker.getChanges (tsserver.js:122689:45)
    at extractFunctionInScope (tsserver.js:130216:43)
    at getFunctionExtractionAtIndex (tsserver.js:129905:24)
    at Object.getEditsForAction (tsserver.js:129502:28)
    at Object.getEditsForRefactor (tsserver.js:123306:41)
    at Proxy.getEditsForRefactor (tsserver.js:134506:32)
    at IOSession.Session.getEditsForRefactor (tsserver.js:144236:59)
    at Session.handlers.ts.createMapFromTemplate._a.<computed> (tsserver.js:143068:61)
    at tsserver.js:144536:88
    at IOSession.Session.executeWithRequestId (tsserver.js:144527:28)
    at IOSession.Session.executeCommand (tsserver.js:144536:33)
    at IOSession.Session.onMessage (tsserver.js:144560:35)
    at Interface.<anonymous> (tsserver.js:145875:27)
    at Interface.emit (events.js:203:13)
    at Interface._onLine (readline.js:316:10)
    at Interface._normalWrite (readline.js:461:12)
    at Socket.ondata (readline.js:172:10)
    at Socket.emit (events.js:203:13)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:276:11)
    at Socket.Readable.push (_stream_readable.js:210:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)
Bug Fixed Failed LS Operation

Most helpful comment

Yes, when I worked on something related, I realized it was caused by a weird issue in how the printer doesn't correctly emit the ?. token - but I was on an airplane at the time. I might still have the fix available.

All 4 comments

The issue causes by "Optional Chaining" searchEditor.ts#L103 , seems that TextChanges has the wrong __pos for the QuestionDotToken token.

The shorter example for reproducing an bug

declare const foo: { n: number } | undefined;
const bar = foo?.n;

I think this is similar to this https://github.com/microsoft/TypeScript/issues/35372 issue.

cc @DanielRosenwasser @RyanCavanaugh

Yes, when I worked on something related, I realized it was caused by a weird issue in how the printer doesn't correctly emit the ?. token - but I was on an airplane at the time. I might still have the fix available.

Still exists in 3.8.3.

Upgrading to TypeScript 3.9.5 solved this.

Was this page helpful?
0 / 5 - 0 ratings