Repository navigation
fix(references): a PROGRAM MAP INCLUDEd from an .inc reaches shim-headed members - #854
Merged
msarson merged 1 commit intoNov 17, 2026
Conversation
…ded members
Find All References on a procedure prototyped in a MAP inside an .inc
that the PROGRAM INCLUDEs missed callers in modules whose MEMBER comes
from an INCLUDE('member.clw') shim. Three gaps: the msarson#602 widening
looked the .inc up as a project source and found none;
isDeclarationReachableFrom took the caller's PROGRAM only from its own
MEMBER edge, so the real .inc was unreachable; and findProcedureViaIndex
then kept a stale copy in a later .red folder. Reachability now follows the shim, a provably
reachable hit ranks above an unknown one, and the new
getIncludingProgramFiles() finds the PROGRAM that includes the .inc.
Tests: new ReferencesIncludedProgramMap.test.ts, 5 tests; the 4 that
compile against the base fail there. Server suite: 4541 passing,
3 pending.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
geircodes
force-pushed
the
fix/references-included-program-map
branch
from
November 6, 2026 07:26
0e9b463 to
326f905
Compare
msarson
added a commit
that referenced
this pull request
Nov 17, 2026
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 happens
A procedure prototyped in a MAP that lives in an .inc, which the PROGRAM INCLUDEs in its global data, and called from modules that get their MEMBER through an
INCLUDE('member.clw')shim:The MAP is the PROGRAM's, so
Helperis visible to every module, but Find All References never reachescaller.clw:Helper PROCEDUREin helpers.clw) or the prototype in helpers.inc: only the prototype and the implementation are listed. The call in caller.clw is missing.Root cause
Three separate gaps, each enough to lose the caller.
1. The #602 widening asks the project for the .inc. A MAP in a PROGRAM is widened to the whole program, but
getFilesToSearchfinds the program by looking up the declaring file among the project's sources:An .inc is rarely a project source file, so this is
undefined, and the search stays at the .inc, its MODULE target and its direct includers.2.
isDeclarationReachableFrom(#483) cannot find a shim-headed module's PROGRAM. It takes the caller's PROGRAM from the caller's own MEMBER edge:caller.clw has no MEMBER edge (the shim has it), so
programisundefined, and the walk up from helpers.inc never meets the caller. The real helpers.inc is reported unreachable (false).3.
findProcedureViaIndexthen picks the copy the graph has never seen. The filter drops onlyfalse:The real helpers.inc is dropped by gap 2. The older copy is outside every project, so the graph answers
undefinedfor it, and it is kept as the only hit. Since that copy has no includers, the search is that one file.Fix
FileRelationshipGraph.isDeclarationReachableFromfinds a module's PROGRAM through its shim too:findProcedureViaIndexranks a hit the graph proves reachable above one it has never seen, and falls back to the old filter when there is none:A new
FileRelationshipGraph.getIncludingProgramFiles(filePath)walks the reverse INCLUDE edges up to the PROGRAM files that include a file at program level. A walk stops at a MEMBER module (its own MEMBER edge or a shim's), because a MAP that arrives there is that module's, as with #322's callout INCs.getFilesToSearchuses it when the project lookup finds nothing:From there the existing #602 branch widens to that program's project as before.
Testing
New
server/src/test/ReferencesIncludedProgramMap.test.ts, 5 tests, on the fixture above. ItsfindProjectForFilemirrors the real lookup, where a file belongs to the project only when it is a listed source, so neither .inc is one. The older copy is in a second .red folder that the declaration index scans first.caller.clw:6,helpers.clw:2,helpers.inc:2isDeclarationReachableFrom(helpers.inc, caller.clw)truegetIncludingProgramFiles(helpers.inc)prog.clwonly, not helpers.clw, which includes it tooWith the three source files reverted to the base, all four tests that compile against the base fail. From the implementation label the result is
helpers.clw:2,helpers.inc:2, without the caller. From the call site it isstale/helpers.inc:3alone.The existing #602 and FAR-from-implementation suites pass unchanged.
Server suite: 4541 passing, 3 pending, 0 failing.
Scope
Left out on purpose:
getIncludingProgramFilescounts every INCLUDE from a PROGRAM file. An .inc INCLUDEd inside a procedure's own data would really be local to that procedure, and FAR would now search the whole program for it. Over-inclusive only, never missing a reference.Noneitem in the .cwproj) already took the existing basename lookup and is unchanged.