fix(PC0013): ignore static built-in calls when resolving a bare record receiver - #551
Merged
Merged
Conversation
…d receiver IInvocationExpression.Instance is null for static built-in class calls as well as for bare implicit-self calls, so GetReceiverTableType resolved IsolatedStorage.Get inside a table to the enclosing table. The resolver now takes the invocation and returns no table for static targets. Fixes #550 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
IInvocationExpression.Instance is null for static built-in class calls as well as for bare self calls. Note the two overloads of GetReceiverTableType, the AL 12 class anchor that stands in for IMethodSymbol.IsStatic, and the regression cause for the fix-false-positive catalog. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The static-target test is only meaningful when the invocation has no receiver operation, so compute it inside that branch instead of on every invocation the ten callers pass through. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…tself GetReceiverTableType now takes the invocation or field access rather than its Instance, so a caller can no longer hand it the ambiguous null receiver of a static built-in call. The static-target check and the receiver fallback live in the one remaining method. 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.
Root cause
IInvocationExpression.Instancereturns null wheneverTargetMethod.IsStaticis true — not only for bare implicit-self calls inside a table. The shared resolverGetReceiverTableType(introduced in 1.3.0 by the receiver-form audit) treated every null instance as "bare self" and fell back to the containing table. Inside a table,IsolatedStorage.Get(...)therefore resolved to the enclosing table and its 2 or 3 arguments were compared with the primary key — triggering PC0013.Fix
GetReceiverTableTypeinOperationExtensions.csnow takes the member operation itself (theIInvocationExpressionorIFieldAccess) instead of itsInstance, so a caller can no longer hand it the ambiguous null receiver. For an invocation with a null instance it first rejects static targets:TargetMethod.IsStatic(available from AL 16.0 / net8.0 SDK)TargetMethod.ContainingSymbol is IClassTypeSymbolwhose name is not"Table"— static built-ins are declared on language classes (IsolatedStorage, NumberSequence, Dialog, System, …), while record built-ins live on theTableclassAll 11 callers across AC, DC, LC, PC and Common pass the operation, which fixes the same latent false positive in:
Get,Insert,Delete,Next,Rename,Countare inMethodOperationMapGetpath had the same exposureFixtures
Three
NoDiagnosticfixtures for PC0013 (the directly reported rule):IsolatedStorageGetInTableProcedure.alIsolatedStorage.Get+Deleteinside a table procedure (issue repro)IsolatedStorageGetInTableTrigger.altrigger OnInsert()with a 2-field PKIsolatedStorageGetInTableExtension.alAll three fail before the fix with "Too many arguments provided" at the markers and pass after.
Test results
RecordGetProcedureArguments— 45/45 pass (includingGetBareSelf,GetRecSelf,GetThisSelf);dotnet test ALCops.sln— 1768 pass, 0 fail; three-TFM Release build — all 7 cops build 0 warnings 0 errors;dotnet format --verify-no-changes— cleanFixes #550
🤖 Generated with Claude Code