Skip to content

fix(FC0002): resolve keyword-named identifiers and Rec through the binder - #636

Merged
Arthurvdv merged 4 commits into
mainfrom
fix/fc0002-keyword-named-identifiers
Nov 17, 2026
Merged

Arthurvdv merged 4 commits into
mainfrom
fix/fc0002-keyword-named-identifiers

Conversation

@Arthurvdv

@Arthurvdv Arthurvdv commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Problem

FC0002 once reported a variable declared Continue: Boolean as "Use 'continue'". The fix for that skipped every identifier whose text equals an AL keyword text (KeywordTexts), which went too far: continue := true on a variable Continue was never reported, and the same text filter hid every member named Type, Code, Date, Value, Action, Report, ... A separate hard-coded Rec name skip also hid rec.SystemId.

SDK facts

  • continue is never a keyword token. SyntaxFacts.GetALKeywordKind has no CONTINUE; continue; is an ExpressionStatementSyntax over an IdentifierNameSyntax, and the binder (Binder.MatchesAmbiguousKeyword) turns it into a continue statement only when the identifier binds to no symbol (runtime 15.0+). GetSymbolInfo on it returns no symbol. Any keyword text used as a name is a plain IdentifierToken, so the text filter never protected a keyword.
  • Built-in class receivers (Xmlport.Run, Codeunit.Run) bind to the LanguageClassTypeSymbol (Xmlport, Codeunit, Page, Report, ...), the same names the :: left side is already checked against.
  • Rec / xRec are synthesized with the literal name Rec at every synthesis site (table, tableextension, page family, request page, report, xmlport, TableNo OnRun local).

Change (CasingMismatchIdentifier.cs only)

  • KeywordTexts removed: every identifier group with a resolved symbol is compared to symbol.Name.
  • The Rec skip in ShouldCollectIdentifier removed.
  • When no symbol resolves, an identifier directly under an ExpressionStatement whose text is the ContinueKeyword text is compared to that keyword text (continue). The kind is read through EnumProvider and SyntaxFacts.GetText, so it compiles on netstandard2.1.

The code fix and CasingMismatchKeyword.cs are unchanged (QuoteIdentifierIfNeeded returns all of these unquoted).

What now reports

  • References to keyword-named user symbols get the declaration casing: continue := true -> Continue, Rec.type -> Type, code() -> Code.
  • Built-in class receivers: XMLPORT.Run -> Xmlport, CODEUNIT.RUN -> Codeunit (also PAGE.RUN, REPORT.RUNMODAL).
  • rec. / REC. -> Rec; a user parameter named Rec or rec gets its declared casing.
  • The loop statement CONTINUE; -> continue.

These are intended new reports. In the BC 29 source: 57 variables named Continue, a lowercase continue: Boolean with continue := true in the Application Test Library, Action: Action, Report: Interface ..., Record: Record ...; rec. 23 times in code, Currpage. twice; hundreds of legacy XMLPORT.Run/Export.

Tests

Ten new HasDiagnostic fixtures (nine with NoDiagnostic twins; the twin of VariableNamedContinueReference is the extended VariableNamedAfterKeyword), four HasFix cases, XmlPortObjectAccess now marks the receiver, and the CasingMismatchKeyword copy of VariableNamedAfterKeyword shows the keyword analyzer stays silent on keyword-named user identifiers.

ContinueStatement and ContinueVariableAndStatementInDifferentScopes are gated at 15.0: a bare continue; only compiles from runtime 15.0 (BC 2025 wave 1).

Red state before the analyzer change (--filter "FullyQualifiedName~CasingMismatch"):

Failed HasDiagnostic("VariableNamedContinueReference")   There is no issue reported for FC0002 at [115...123].
Failed HasDiagnostic("VariableNamedContinueDeclaredLowercase")   ... at [109...117].
Failed HasDiagnostic("XmlPortObjectAccess")   ... at [191...198].
Failed HasDiagnostic("ContinueVariableAndStatementInDifferentScopes")   ... at [112...120].
Failed HasDiagnostic("ContinueStatement")   ... at [166...174].
Failed HasDiagnostic("BuiltInClassReceiver")   ... at [74...82].
Failed HasDiagnostic("RecInTableNoCodeunit")   ... at [90...93].
Failed HasDiagnostic("RecInTableTrigger")   ... at [125...128].
Failed HasDiagnostic("KeywordNamedMembers")   ... at [168...172].
Failed HasDiagnostic("RecParameter")   ... at [212...215].
Failed HasDiagnostic("RecOnPage")   ... at [124...127].
Failed HasFix("VariableNamedContinueReference")   Cannot find CodeFix with index 0 at [110...118].
Failed HasFix("ContinueStatement")   Cannot find CodeFix with index 0 at [133...141].
Failed HasFix("RecOnPage")   Cannot find CodeFix with index 0 at [106...109].
Failed HasFix("BuiltInClassReceiver")   Cannot find CodeFix with index 0 at [74...81].
Failed!  - Failed: 15, Passed: 95, Skipped: 0, Total: 110

After: 110/110 FC0002, 241/241 FormattingCop (net10.0), 84/84 CasingMismatchDeclaration on the net8.0 binary; three-TFM Release build and dotnet format --verify-no-changes clean.

Docs: companion PR ALCops/alcops.dev#224

Part of #135

🤖 Generated with Claude Code

Arthurvdv and others added 3 commits November 17, 2026 11:11
…tinue and Rec casing

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…nder; case the continue statement

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Arthurvdv
Arthurvdv merged commit 53b2eaa into main Nov 17, 2026
53 checks passed
@Arthurvdv
Arthurvdv deleted the fix/fc0002-keyword-named-identifiers branch November 17, 2026 13:18
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