Skip to content

fix(FC0002): scope-aware identifier grouping prevents cross-method false positives#308

Merged
Arthurvdv merged 3 commits into
release/v0.9.0from
fix/fc0002-cross-scope-grouping
May 23, 2026
Merged

fix(FC0002): scope-aware identifier grouping prevents cross-method false positives#308
Arthurvdv merged 3 commits into
release/v0.9.0from
fix/fc0002-cross-scope-grouping

Conversation

@Arthurvdv
Copy link
Copy Markdown
Member

Summary

Fixes #307

Root cause: ResolveIdentifiers and ResolveQualifiedNames grouped identifiers by text across the entire AL object, using one representative for symbol resolution. When the same identifier text existed in multiple methods referencing differently-cased parameters (e.g., MyTable in one method, myTable in another), the last occurrence's resolution was applied to all occurrences, producing false positives.

Fix: Track the containing method/trigger scope during the syntax tree walk and group by (text + scope) instead of just text. Each method gets its own representative, so symbol resolution stays local to its scope.

Changes

  • CasingMismatchIdentifier.cs: Added scope tracking to WalkNode, updated ResolveIdentifiers and ResolveQualifiedNames to group by (text, scope)
  • Added ScopedTextComparer helper for case-insensitive text + reference-equality scope comparison
  • 3 new test fixtures covering cross-scope scenarios (NoDiagnostic + HasDiagnostic)

Test results

All 75 FormattingCop tests pass, including 3 new regression tests.

Arthurvdv and others added 3 commits May 23, 2026 17:14
…lse positives

The ResolveIdentifiers and ResolveQualifiedNames methods grouped identifiers
by text across the entire object, using one representative for symbol
resolution. When the same identifier text existed in multiple methods
referencing differently-cased parameters, the last occurrence's resolution
contaminated all earlier occurrences, producing false positives.

Fix: track the containing method/trigger scope during tree walk and group by
(text + scope). Each method gets its own representative, so symbol resolution
stays local to its scope.

Closes #307

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover additional scenarios where global variables conflict with:
- Parameters (direct and this-prefixed access)
- Return values
- Local variables

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The 'this' keyword was introduced in AL v14.0. Guard the
GlobalVarAndParamThisPrefix test cases to skip on older SDK versions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Arthurvdv Arthurvdv merged commit 574684a into release/v0.9.0 May 23, 2026
43 checks passed
@Arthurvdv Arthurvdv deleted the fix/fc0002-cross-scope-grouping branch May 23, 2026 17:43
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.

1 participant