-
Notifications
You must be signed in to change notification settings - Fork 714
Fix inverted condition for module references in findallreferences #1780
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
The condition checking whether to return early for module references was inverted. The TypeScript implementation returns early when the symbol is NOT transient, but the Go code was returning early only when it IS transient. This caused module symbols (whose declarations are SourceFiles with no parent) to be passed to getReferencedSymbolsForSymbol, which then called skipPastExportOrImportSpecifierOrUnion. That function would panic when encountering a declaration without a parent for a non-transient symbol. The fix aligns the Go implementation with the TypeScript source by checking for `== 0` instead of `!= 0` on the transient flag. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot finished work on behalf of
jakebailey
October 1, 2025 14:57
jakebailey
reviewed
Oct 1, 2025
The test should be in internal/fourslash/tests/ instead of the gen/ subdirectory, as the gen/ directory is only for generated tests. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot finished work on behalf of
jakebailey
October 1, 2025 15:13
jakebailey
reviewed
Oct 1, 2025
The test cannot reproduce the crash because getReferencedSymbolsForModule is not yet implemented. The fix is correct (matches TypeScript source), but cannot be verified with a test until that function is implemented. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot finished work on behalf of
jakebailey
October 1, 2025 17:37
Implemented a minimal version of getReferencedSymbolsForModule that returns module declarations as references. This, combined with the corrected condition (checking for non-transient instead of transient), prevents the crash when highlighting import paths. The crash occurred because: 1. GetSymbolAtLocation on an import string returns a module symbol 2. getReferencedSymbolsForModuleIfDeclaredBySourceFile is called and now returns results 3. The old condition checked for transient symbols, causing non-transient module symbols to fall through to getReferencedSymbolsForSymbol 4. That function calls skipPastExportOrImportSpecifierOrUnion which panics on SourceFile declarations without parents The fix ensures non-transient module symbols return early with the module references, preventing the panic. Added test TestDocumentHighlightImportPath that verifies document highlights work on import paths and would hang/crash with the old condition. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot finished work on behalf of
jakebailey
October 1, 2025 18:01
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.