Repository navigation
fix(FC0002): resolve keyword-named identifiers and Rec through the binder - #636
Merged
Merged
Conversation
…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>
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.
Problem
FC0002 once reported a variable declared
Continue: Booleanas "Use 'continue'". The fix for that skipped every identifier whose text equals an AL keyword text (KeywordTexts), which went too far:continue := trueon a variableContinuewas never reported, and the same text filter hid every member namedType,Code,Date,Value,Action,Report, ... A separate hard-codedRecname skip also hidrec.SystemId.SDK facts
continueis never a keyword token.SyntaxFacts.GetALKeywordKindhas noCONTINUE;continue;is anExpressionStatementSyntaxover anIdentifierNameSyntax, and the binder (Binder.MatchesAmbiguousKeyword) turns it into a continue statement only when the identifier binds to no symbol (runtime 15.0+).GetSymbolInfoon it returns no symbol. Any keyword text used as a name is a plainIdentifierToken, so the text filter never protected a keyword.Xmlport.Run,Codeunit.Run) bind to theLanguageClassTypeSymbol(Xmlport,Codeunit,Page,Report, ...), the same names the::left side is already checked against.Rec/xRecare synthesized with the literal nameRecat every synthesis site (table, tableextension, page family, request page, report, xmlport,TableNoOnRunlocal).Change (
CasingMismatchIdentifier.csonly)KeywordTextsremoved: every identifier group with a resolved symbol is compared tosymbol.Name.Recskip inShouldCollectIdentifierremoved.ExpressionStatementwhose text is theContinueKeywordtext is compared to that keyword text (continue). The kind is read throughEnumProviderandSyntaxFacts.GetText, so it compiles on netstandard2.1.The code fix and
CasingMismatchKeyword.csare unchanged (QuoteIdentifierIfNeededreturns all of these unquoted).What now reports
continue := true->Continue,Rec.type->Type,code()->Code.XMLPORT.Run->Xmlport,CODEUNIT.RUN->Codeunit(alsoPAGE.RUN,REPORT.RUNMODAL).rec./REC.->Rec; a user parameter namedRecorrecgets its declared casing.CONTINUE;->continue.These are intended new reports. In the BC 29 source: 57 variables named
Continue, a lowercasecontinue: Booleanwithcontinue := truein the Application Test Library,Action: Action,Report: Interface ...,Record: Record ...;rec.23 times in code,Currpage.twice; hundreds of legacyXMLPORT.Run/Export.Tests
Ten new HasDiagnostic fixtures (nine with NoDiagnostic twins; the twin of
VariableNamedContinueReferenceis the extendedVariableNamedAfterKeyword), four HasFix cases,XmlPortObjectAccessnow marks the receiver, and the CasingMismatchKeyword copy ofVariableNamedAfterKeywordshows the keyword analyzer stays silent on keyword-named user identifiers.ContinueStatementandContinueVariableAndStatementInDifferentScopesare gated at 15.0: a barecontinue;only compiles from runtime 15.0 (BC 2025 wave 1).Red state before the analyzer change (
--filter "FullyQualifiedName~CasingMismatch"):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-changesclean.Docs: companion PR ALCops/alcops.dev#224
Part of #135
🤖 Generated with Claude Code