Skip to content

Commit 0415626

Browse files
committed
fix(lint): read the undeclared-hop refusal through the tabled obj/def receivers
The #5017 receiver scan reads every member access in the rule's source; the closure now walks the object's fields through the receivers the scan already tables instead of adding new ones. Claude-Session: https://claude.ai/code/session_01SE5iTKQC8i5LBRywMuQZmt Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6606016 commit 0415626

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

‎packages/lint/src/validate-expressions.ts‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,22 +1982,21 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression
19821982
if (!source) return;
19831983
const traversals = analyzeRelationshipTraversals(source, 'record')?.traversals;
19841984
if (!traversals || traversals.size === 0) return;
1985-
const own = objects.find((o) => o.name === objectName);
1986-
if (!own) return;
1987-
const defs = new Map(fieldEntries(own));
1988-
for (const [field, columns] of traversals) {
1989-
const target = referenceTargetOf(defs.get(field))?.trim();
1990-
if (!target || isStoredMetadataBodyObject(target)) continue;
1991-
const declared = fieldIndex.get(target);
1992-
if (!declared) continue;
1993-
for (const column of [...columns].sort()) {
1994-
if (column === 'id' || declared.includes(column)) continue;
1995-
issues.push({
1996-
where,
1997-
message: undeclaredHopFieldMessage(objectName, field, target, column),
1998-
source,
1999-
severity: 'error',
2000-
});
1985+
for (const obj of objects) {
1986+
if (obj.name !== objectName) continue;
1987+
for (const [field, def] of fieldEntries(obj)) {
1988+
const columns = traversals.get(field);
1989+
const target = columns ? referenceTargetOf(def)?.trim() : undefined;
1990+
if (!columns || !target || isStoredMetadataBodyObject(target) || !fieldIndex.has(target)) continue;
1991+
for (const column of [...columns].sort()) {
1992+
if (column === 'id' || fieldIndex.get(target)?.includes(column)) continue;
1993+
issues.push({
1994+
where,
1995+
message: undeclaredHopFieldMessage(objectName, field, target, column),
1996+
source,
1997+
severity: 'error',
1998+
});
1999+
}
20012000
}
20022001
}
20032002
};

0 commit comments

Comments
 (0)