Skip to content

fix(completion): resolve alias shadowing in nested scopes - #46

Merged
melonamin merged 2 commits into
masterfrom
bb/fix-issue-41-alias-shadowing-thr_abdcknkay3
Aug 11, 2026
Merged

melonamin merged 2 commits into
masterfrom
bb/fix-issue-41-alias-shadowing-thr_abdcknkay3

Conversation

@melonamin

Copy link
Copy Markdown
Member

Summary

  • track SELECT scopes from completion tokens, including nested queries and set-operation branches
  • resolve qualified table aliases through the cursor's innermost-to-outer scope chain
  • preserve correlated outer aliases when no inner binding shadows them
  • enable the two issue regression tests and add correlated-subquery coverage

Root cause

Completion table extraction is intentionally tolerant of incomplete SQL, but it flattened every FROM and JOIN in a statement. Filtering u. columns therefore matched both inner and outer bindings when nested SELECTs reused u.

The resolver now derives scope boundaries from tokens, which still works when the cursor leaves an incomplete expression such as u.. Qualified completion uses only visible bindings and drops outer labels shadowed by a nearer SELECT. Existing unqualified and CTE enrichment behavior remains unchanged.

Validation

  • cargo fmt --all -- --check
  • cargo test -p flowscope-core --test completion_items alias_shadowing
  • cargo test -p flowscope-core --test completion_items
  • cargo test -p flowscope-core --test completion_snapshots
  • cargo clippy -p flowscope-core -- -D warnings
  • just test-core

Fixes #41

@melonamin
melonamin merged commit ab5da53 into master Aug 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IntelliSense: alias-shadowing correctness in nested scopes

1 participant