Repository navigation
A local declared again in its own scope is offered and called as the one in effect - #438
Merged
Merged
Conversation
…one in effect Luau keeps every declaration a scope makes among its bindings, an unordered_map keyed by each local's node, and so ordered by the address the parser put it at. Its autocomplete, and a fragment's check bringing in the last check's type of each name the fragment uses, look a local up by its name there and take the first the map gives. Where a scope declares a name twice, which one that was changed from run to run: after `local function test()` and `local test = 1`, `test` was offered as the function in one run and as the number in the next, over the whole script and over a fragment alike, and signature help over a fragment could show the function a later declaration had shadowed. alluaufragment 2 failed in about a third of runs on scope3.lsl, whose SLua has both at its top level: the fragment and the whole script picked differently. While Luau is asked, ALLuauShadowed now takes out of each scope of the module the declarations of a name other than the one in effect at the place -- the last declared before it, but for one whose `local` the place is in -- and puts them back after. Where a fragment declares a name again beside the one it brought from the last check, both are in the fragment's own scope, which Luau makes and reads in the one call; there the whole script answers instead. Luau is slua's, so this is worked around here rather than patched. alluaufragment 6. alluaufragment passes 40 runs in a row, and 16 with the new solver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
6 of 9 tasks
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 the intermittent failure of
INTEGRATION_TEST_alluaufragmenttest 2 (about 5 runs in 12 on macOS arm64):Cause
Luau keeps every declaration a scope makes among its bindings, an
unordered_mapkeyed by each local's AST node, so ordered by the address the parser put it at. Two places look a local up by name there and take the first the map gives:autocompleteStatement/autocompleteExpression), over the whole script and over a fragment;cloneTypesFromFragment→linearSearchForBindingPair).Where one scope declares a name twice, which declaration that is changes from run to run. scope3.lsl, written as SLua, has
local function test()andlocal test = 1at its top level, so attest = 2the fragment and the whole script picked independently. Both directions were seen (1|3and3|1), so the whole-script answer was random too, not only the fragment's. Signature help over a fragment could likewise show the function a later declaration had shadowed.Fix
ALLuauShadowed(indra/alscript/luau/alluaushadowed.{h,cpp}), held aroundLuau::autocompleteand both fragment calls, takes out of each scope of the module the declarations of a name other than the one in effect at the place — the last declared before it, but for one whoselocalthe place is in — and puts them back afterwards.Where a fragment declares a name again beside the one it brought from the last check, both sit in the fragment's own scope, which Luau makes and reads in the one call; there the fragment declines and the whole script answers.
Luau is slua's, so this is worked around here rather than patched.
Tests
alluaufragmenttest 6: four completion places and a signature-help call over a redeclared local, over 24 rounds that move the addresses. It failed in every run before the fix, and fails in every run with any one of the three guards taken out.alluaufragmentpassed 40 runs in a row with the old solver and 16 with the new; the corpus tallies are unchanged (890 of 1069 Tailslide places still answered over a fragment)._newsolvervariants included. The newview tests weren't run; none of them asks for a completion or signature help.Not pinned down: why the flake first showed after 310a8df. Luau's pick is address-dependent either way, so the likeliest reason is that scope3.lsl converts (or converts this way) only with the Tailslide slua carries.
🤖 Generated with Claude Code