fix rename/references missing asm output operands - #3243
Open
DaliVana wants to merge 1 commit into
Open
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
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.
Fixes #3222
Renaming a variable did not update its occurrence inside an inline
asmoutput operand:The same occurrence was also missing from textDocument/references and textDocument/documentHighlight.
Cause
In the grammar, an asm output operand without -> is a bare IDENTIFIER — parseAsmOutputItem consumes the token and creates no AST node for it (only the -> type form stores a node). Reference collection (Builder.referenceNode) walks AST nodes, so the operand token was invisible. Asm inputs work because their operand is a full expression node yielded by the child iterator (#1142); outputs with -> likewise.
Fix
Handle .asm_simple/.@"asm" in Builder.referenceNode: for each output item, the operand token is nodeMainToken(output) + 4 (the same layout already relied on in semantic_tokens.zig and the ChildIterator). The -> T form is skipped (already covered as a child node). The operand then goes through the same treatment as the .identifier case: the _/primitive/escaped-identifier guard, lookupSymbolGlobal, alias resolution, and target_symbol.eql — added per matching output, so multiple outputs referencing the same variable all get collected.
This fixes rename, find-references, and document highlight in one place, since all three share symbolReferences.
Tests
Five new cases in test "asm":