Skip to content

fix(pascal): detect unqualified paren-less calls (DoWork;) - #1641

Open
equipados wants to merge 1 commit into
colbymchenry:mainfrom
equipados:fix/pascal-unqualified-parenless-calls
Open

fix(pascal): detect unqualified paren-less calls (DoWork;)#1641
equipados wants to merge 1 commit into
colbymchenry:mainfrom
equipados:fix/pascal-unqualified-parenless-calls

Conversation

@equipados

Copy link
Copy Markdown

What

A Pascal statement that is nothing but an identifier — DoWork; — is an
unqualified call to a parameterless routine. visitPascalBlock didn't treat it
as one, so only the parenthesised form DoWork() produced a calls edge.

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 tools
didn't return a wrong answer — they returned an empty one, which is harder to
notice.

The qualified form (Obj.Free;) is already handled by
extractPascalParenlessCall (thanks — that landed in 1.5). This is the same
idea one step less qualified.

Measured on a real Delphi codebase

285 .pas/.dpr files from a production Delphi 10.2 ERP (~1.1M LOC):

calls edges
1.5.0 as-is 2316
with this patch 2711
+395 (+17%)

How it's scoped

Gated on the identifier being the whole statement:

child.type === 'identifier' &&
node.type === 'statement' &&
node.namedChildCount === 1

Anywhere else — assignment RHS, if condition, any expression — a bare
identifier is indistinguishable from a variable read without type information,
so those are deliberately left alone. That is what the second test locks in:

procedure TFoo.DoThing;
var
  Total, Other: Integer;   // and TFoo has a method also called Total
begin
  Other := Total;                    // variable read, NOT a call
  if Total > 0 then Other := 0;      // variable read, NOT a call
end;

isCalled('TFoo::Total') must stay false.

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 my
machine (3× PHP include, 1× C/C++ include, 1× gitlink) are identical before and
after the change — pre-existing and unrelated, likely Windows-specific.

tsc --noEmit clean.

Notes

Only src/extraction/tree-sitter.ts changes; Pascal is not part of the Rust
kernel so there is no parity fixture to update.

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.
@danusha2345

Copy link
Copy Markdown
Contributor

Took this into a local integration build (current main + the open fixes I could merge cleanly) and ran the full suite with the native kernel: 245 files, 4323 passed, 0 failed. No regression on the codegraph repo's own index after a forced re-index. Looks good to me.

@equipados

equipados commented Sep 4, 2026 via email

Copy link
Copy Markdown
Author

@danusha2345 danusha2345 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving as a fellow contributor, with one caveat worth stating plainly: my review does not unblock the merge. I have no write access to this repository, so REVIEW_REQUIRED can only be cleared by @colbymchenry — this shows up as an approval in the list, nothing more. Treating it as a validation record rather than a gate.

What it rests on: the branch merged clean into a local integration build of current main plus the other open fixes, full suite with the native kernel 245 files / 4323 passed / 0 failed, and a forced re-index of codegraph's own repo with no edge regressions.

No rebase needed — GitHub still reports the PR MERGEABLE against today's main (unchanged since b9ca4b7, 31 Aug), and the branch is one commit ahead of the merge-base. Rebasing would only change the SHA.

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.

2 participants