Skip to content

TS Server fatal error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isUnaryExpression'. #53114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stefan520 opened this issue Mar 5, 2023 · 16 comments · Fixed by #53666
Labels
Fix Available A PR has been opened for this issue Needs More Info The issue still hasn't been fully clarified

Comments

@stefan520
Copy link

Type: Bug

❗️❗️❗️ Please fill in the sections below to help us diagnose the issue ❗️❗️❗️

TypeScript Version: 5.1.0-dev.20230304

Steps to reproduce crash

  1. Open up visual studio

TS Server Log

❗️ Server logging disabled. To help us fix crashes like this, please enable logging by setting:

"typescript.tsserver.log": "verbose"

After enabling this setting, future crash reports will include the server log.

TS Server Error Stack

Server: semantic

Error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isUnaryExpression'.
    at cast (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:3440:16)
    at Object.parenthesizeOperandOfPrefixUnary (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:21770:50)
    at Object.createPrefixUnaryExpression (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:23899:41)
    at parsePrefixUnaryExpression (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33504:32)
    at parseSimpleUnaryExpression (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33556:16)
    at parseUnaryExpressionOrHigher (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33538:35)
    at parseBinaryExpressionOrHigher (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33456:25)
    at parseAssignmentExpressionOrHigher (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33129:18)
    at parseExpression (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33095:16)
    at doOutsideOfContext (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:30792:12)
    at allowInAnd (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:30813:12)
    at parseExpressionOrLabeledStatement (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:34607:24)
    at parseStatement (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:34839:12)
    at parseListElement (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:31563:12)
    at parseList (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:31548:19)
    at parseSourceFileWorker (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:30608:24)
    at Object.parseSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:30441:20)
    at createSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:30274:21)
    at createLanguageServiceSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135181:22)
    at acquireOrUpdateDocument (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:132099:26)
    at Object.acquireDocumentWithKey (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:132024:12)
    at getOrCreateSourceFileByPath (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135505:31)
    at Object.getOrCreateSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135485:14)
    at c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135417:42
    at Object.getSourceFileWithCache [as getSourceFile] (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:117176:24)
    at findSourceFileWorker (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119508:23)
    at findSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119428:20)
    at c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119377:22
    at getSourceFileFromReferenceWorker (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119346:26)
    at processSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119375:5)
    at processRootFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119171:5)
    at c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:117956:41
    at forEach (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:2307:22)
    at createProgram (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:117956:5)
    at synchronizeHostData (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135441:15)
    at Object.getProgram (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135513:5)
    at ConfiguredProject2.updateGraphWorker (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:172332:41)
    at ConfiguredProject2.updateGraph (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:172269:32)
    at ConfiguredProject2.updateGraph (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:173487:24)
    at _ProjectService.createLoadAndUpdateConfiguredProject (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:175098:13)
    at _ProjectService.assignProjectToOpenedScriptInfo (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:176189:26)
    at c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:176469:64
    at flatMap (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:2555:17)
    at _ProjectService.applyChangesInOpenFiles (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:176469:24)
    at updateOpen (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:177617:29)
    at c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:180167:69
    at IpcIOSession.executeWithRequestId (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:180159:14)
    at IpcIOSession.executeCommand (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:180167:29)
    at IpcIOSession.onMessage (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:180209:51)
    at process.<anonymous> (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:181777:14)
    at process.emit (node:events:526:28)
    at emit (node:internal/child_process:938:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

VS Code version: Code 1.76.0 (92da9481c0904c6adfe372c12da3b7748d74bdcb, 2023-03-01T10:22:44.506Z)
OS version: Windows_NT x64 10.0.22621
Modes:
Sandboxed: No

System Info
Item Value
CPUs AMD Ryzen 7 5800X 8-Core Processor (16 x 3800)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 31.93GB (18.80GB free)
Process Argv --folder-uri file:///c%3A/Coding/MadegoConsumerApp --crash-reporter-id 0751c08f-edc1-48a4-8acc-5ac0ff5a8c75
Screen Reader no
VM 40%
Extensions (38)
Extension Author (truncated) Version
vscode-sql-formatter adp 1.4.4
vscode-color ans 0.4.5
heroicons-preview BBu 1.0.0
vscode-intelephense-client bme 1.9.5
vscode-tailwindcss bra 0.9.7
multi-cursor-case-preserve Car 1.0.5
json-tree-view Cha 2.6.0
path-intellisense chr 2.8.4
javascript-ejs-support Dig 1.3.3
netcore-snippets dog 3.15.2
xml Dot 2.5.1
es7-react-js-snippets dsz 4.4.3
gitlens eam 13.3.1
vscode-html-css ecm 1.13.1
prettier-vscode esb 9.10.4
auto-rename-tag for 0.1.10
vscode-mysql for 0.4.1
vscode-chatgpt gen 3.9.4
copilot Git 1.77.9225
vscode-pull-request-github Git 0.58.2
bootstrap5-snippets Han 1.2.5
rest-client hum 0.25.1
mysql-syntax jak 1.3.1
dupchecker jia 0.1.7
sequelize-snippets kvc 1.0.0
font-awesome-codes-css med 0.1.1
vscode-typescript-next ms- 5.1.20230304
vsliveshare ms- 1.0.5832
sftp Nat 1.16.2
material-icon-theme PKi 4.24.0
vscode-css-peek pra 4.2.0
tpl-lang qiq 0.0.1
vscode-thunder-client ran 2.5.0
asp-classic-support-v2 SUR 0.7.1
Web-VSCode-Extensions Syn 20.4.48
msbuild-project-tools tin 0.4.9
vscode-import-cost wix 3.3.0
html-css-class-completion Zig 1.20.0
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vsclangdf:30486550
c4g48928:30535728
dsvsc012:30540252
pynewext54:30669237
azure-dev_surveyone:30548225
pyindex848:30662994
nodejswelcome1cf:30587006
3biah626:30602489
pyind779:30671433
89544117:30613380
pythonsymbol12:30671437
vsccsb:30677849

@mjbvz mjbvz transferred this issue from microsoft/vscode Mar 6, 2023
@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Mar 6, 2023
@RyanCavanaugh
Copy link
Member

We'd really need to see the code that causes this

@Alekzv9
Copy link

Alekzv9 commented Mar 31, 2023

I have the same issue. For me is a expo/react-native project. I cannot share the code - other projects to works fine, this started happening after updating to last version of vscode.

@Alekzv9
Copy link

Alekzv9 commented Mar 31, 2023

@stefan520 I had to download an older version, for me January version works fine
https://code.visualstudio.com/updates/v1_77

@ghost
Copy link

ghost commented Apr 3, 2023

Same problem here. My project is an expo/react-native.

@ghost
Copy link

ghost commented Apr 3, 2023

Works after downgrade to Feb/23 version

https://code.visualstudio.com/updates/v1_76

@RyanCavanaugh
Copy link
Member

We're tracking this at #53637 and really need a repro! Please help!

@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2023
@RyanCavanaugh
Copy link
Member

@lovveapp would you be able to post a (redacted if needed) zip file or other way to reproduce this crash? Thanks!

@RyanCavanaugh
Copy link
Member

@Alekzv9 would you be able to post a (redacted if needed) zip file or other way to reproduce this crash? Thanks!

@RyanCavanaugh
Copy link
Member

@stefan520 would you be able to post a (redacted if needed) zip file or other way to reproduce this crash? Thanks!

@ghost
Copy link

ghost commented Apr 4, 2023

@RyanCavanaugh

npx create-react-app test-app --template expo-template-tabs
cd test-app
eas update --auto
ls -al ./dist

Note the the dist folder is the issue here. (as noted in this related post #53637 (comment))

archive.tar.gz

@RyanCavanaugh
Copy link
Member

@vecsq thank you!

@RyanCavanaugh
Copy link
Member

Repro 1 is

~< <

Repro 2 I'll do tomorrow morning 😅

@jakebailey
Copy link
Member

Second is [#]=.

@jakebailey
Copy link
Member

jakebailey commented Apr 5, 2023

Sent a PR for repro 2, that was caused by my SFT PR adding in a node check.

Repro 1 is a bad case of our parser's recovery.

In JS, we parse ~ as unary, then < as JSX, but it is treated as self closing fragment, leaving < afterwards, which we then have special code in the parser to handle because it's common to write <div></div><div></div> without parens and end up with a bad tree. The recovery method instead returns an expression that effectively looks like <,< instead and that's not a unary, so the cast fails.

I have no idea why this is new, though.

Probably the fix is to instead ensure the returned node is a unary, so, wrap the binary expression in another faked up unary node.

@jakebailey
Copy link
Member

jakebailey commented Apr 5, 2023

Lol, no, repro 1 is a typo. Ignore all of that above.

No, I'm wrong, it's not at typo. This recovery mechanism just doesn't appear to work. Still, unsure why it's new.

@jakebailey
Copy link
Member

Oh, this is because of #52667.

Yay, both crashes are my fault!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants