fix(pascal): detect unqualified paren-less calls (DoWork;) - #1641
Open
equipados wants to merge 1 commit into
Open
fix(pascal): detect unqualified paren-less calls (DoWork;)#1641equipados wants to merge 1 commit into
DoWork;)#1641equipados wants to merge 1 commit into
Conversation
A statement that is nothing but an identifier is an unqualified call to a parameterless routine. Pascal allows dropping the parens on a no-arg call and Delphi codebases do so by convention, so `visitPascalBlock` was missing the majority of intra-unit calls: only `DoWork()` was recorded, never `DoWork;`. The qualified form (`Obj.Free;`) is already handled by `extractPascalParenlessCall`; this is the same idea one step less qualified. Gated on the identifier BEING the whole statement (`node.type === 'statement' && node.namedChildCount === 1`). Anywhere else — assignment RHS, condition, any expression — a bare identifier is indistinguishable from a variable read without type information, so those are left alone. Covered by a negative test.
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.
What
A Pascal statement that is nothing but an identifier —
DoWork;— is anunqualified call to a parameterless routine.
visitPascalBlockdidn't treat itas one, so only the parenthesised form
DoWork()produced acallsedge.Pascal lets a no-arg routine drop its parens, and in Delphi that is the
convention rather than the exception, so on a real Delphi codebase most
intra-unit calls were invisible to
callers/callees/impact. Those toolsdidn't return a wrong answer — they returned an empty one, which is harder to
notice.
The qualified form (
Obj.Free;) is already handled byextractPascalParenlessCall(thanks — that landed in 1.5). This is the sameidea one step less qualified.
Measured on a real Delphi codebase
285
.pas/.dprfiles from a production Delphi 10.2 ERP (~1.1M LOC):callsedgesHow it's scoped
Gated on the identifier being the whole statement:
Anywhere else — assignment RHS,
ifcondition, any expression — a bareidentifier is indistinguishable from a variable read without type information,
so those are deliberately left alone. That is what the second test locks in:
isCalled('TFoo::Total')must stayfalse.Tests
Two added next to the existing paren-less test in
__tests__/resolution.test.ts:extracts UNQUALIFIED paren-less calls (Reset;, the dominant Delphi idiom)— fails without the change, passes with it.does not turn a bare identifier that is NOT a whole statement into a call— the negative case above.resolution.test.ts+extraction.test.ts: 788 passed. The 5 failures on mymachine (3× PHP include, 1× C/C++ include, 1× gitlink) are identical before and
after the change — pre-existing and unrelated, likely Windows-specific.
tsc --noEmitclean.Notes
Only
src/extraction/tree-sitter.tschanges; Pascal is not part of the Rustkernel so there is no parity fixture to update.