Skip to content
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

Creating a new .qs file in a project folder where the qsharp.json has files list triggers panic #2090

Closed
swernli opened this issue Jan 6, 2025 · 0 comments · Fixed by #2109
Assignees
Labels
bug Something isn't working needs triage

Comments

@swernli
Copy link
Collaborator

swernli commented Jan 6, 2025

When editing a Q# project that has an explicit files list in the qsharp.json, if you create a new .qs file in the src folder before adding it to the explicit files list the language service panics:

2025-01-06 12:34:24.024 [error] [wasm] Wasm panic occurred: panicked at language_service/src/compilation.rs:297:14:
source should exist in the user source map

Stack:

Error: 
	at imports.wbg.__wbg_new_0232637a3cb0b1a7 (file:///Users/swernli/.vscode/extensions/quantum.qsharp-lang-vscode-dev-1.12.2/out/extension.js#vscode-extension:32866:17)
	at wasm://wasm/00e6c39a:wasm-function[3681]:0x312e28
	at wasm://wasm/00e6c39a:wasm-function[2061]:0x2c84c4
	at wasm://wasm/00e6c39a:wasm-function[2834]:0x2fe7b4
	at wasm://wasm/00e6c39a:wasm-function[2726]:0x2faeb5
	at wasm://wasm/00e6c39a:wasm-function[1851]:0x2a8fac
	at LanguageService.get_code_lenses (file:///Users/swernli/.vscode/extensions/quantum.qsharp-lang-vscode-dev-1.12.2/out/extension.js#vscode-extension:32709:12)
	at QSharpLanguageService.getCodeLenses (file:///Users/swernli/.vscode/extensions/quantum.qsharp-lang-vscode-dev-1.12.2/out/extension.js#vscode-extension:33815:33)
	at QSharpCodeLensProvider.provideCodeLenses (file:///Users/swernli/.vscode/extensions/quantum.qsharp-lang-vscode-dev-1.12.2/out/extension.js#vscode-extension:39781:51)
	at mf.provideCodeLenses (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:121:200273)
	at vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:121:229194
	at Rt.s (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:121:228034)
	at Rt.$provideCodeLenses (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:121:229182)
	at N0.S (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:30:77539)
	at N0.Q (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:30:77319)
	at N0.M (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:30:76370)
	at N0.L (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:30:75513)
	at tu.value (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:30:74310)
	at C.B (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:29:746)
	at C.fire (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:29:964)
	at GN.e.port1.onmessage (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/worker/extensionHostWorkerMain.js:145:3409)

Somehow this case should fail gracefully, ideally with feedback to the user that the file is not part of the project and won't be included in any compilation. Stretch goal could be a quick fix to put it into the files list from within that new file, but could also be just a warning that the file is not included (similar to how rust-analyzer does it).

@swernli swernli added bug Something isn't working needs triage labels Jan 6, 2025
github-merge-queue bot pushed a commit that referenced this issue Jan 24, 2025
…d of `qsharp.json` (#2109)

Fixes #2090

Notably, this also changes how we treat the `files` field in
`qsharp.json` for local projects their local dependencies.

Previously, if the `qsharp.json` explicitly listed any `files` , that
list would take priority and we would skip crawling the directory.

With this change: we always crawl the `src/` directory and include all
found `*.qs` files in the project. But we raise an explicit error to the
user if any of those files are missing from the `files` list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants