Skip to content

Commit 72632fb

Browse files
committed
fix(resolver): clarify scope guard and :this key convention in accessor this-dispatch (#1351)
- Add comment to extractConstDeclarators explaining that the function-scope guard is upheld by the caller (extractConstantsWalk) — future refactors must add a hasFunctionScopeAncestor check before calling extractObjectLiteralFunctions from any other context. - Add comment at the setTypeMapEntry call noting that ':' is a reserved separator for Phase 8.3f keys and cannot collide with real JS identifier names.
1 parent 2b587df commit 72632fb

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/extractors/javascript.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,10 @@ function extractConstDeclarators(declNode: TreeSitterNode, definitions: Definiti
498498
endLine: nodeEndLine(declNode),
499499
});
500500
// Phase 8.3f: extract function/arrow properties from object literals.
501+
// Scope guard: extractConstDeclarators is only called from extractConstantsWalk, which
502+
// already skips const declarations inside function scopes (line ~412). So these definitions
503+
// are always top-level. Do not call extractObjectLiteralFunctions from any other context
504+
// without adding a hasFunctionScopeAncestor guard first.
501505
if (valueN.type === 'object') {
502506
extractObjectLiteralFunctions(valueN, nameN.text, definitions);
503507
}
@@ -1776,6 +1780,8 @@ function handleDefinePropertyTypeMap(
17761780
setTypeMapEntry(typeMap, `${arg0.text}.${key}`, target, 0.85);
17771781
}
17781782
// Phase 8.3f: { get: getter } and/or { set: setter } → this inside each accessor is arg0 (obj)
1783+
// Key format: '<accessorName>:this' — colon is a reserved separator used only by this phase.
1784+
// JS identifiers cannot contain ':', so this key never collides with real variable names.
17791785
for (const accessor of findDescriptorAccessors(arg2)) {
17801786
setTypeMapEntry(typeMap, `${accessor}:this`, arg0.text, 0.85);
17811787
}

0 commit comments

Comments
 (0)