Skip to content

Copy loc objects in stampLoc instead of sharing references#135

Merged
laat merged 5 commits intomasterfrom
fix/stamploc-shared-ref
Apr 12, 2026
Merged

Copy loc objects in stampLoc instead of sharing references#135
laat merged 5 commits intomasterfrom
fix/stamploc-shared-ref

Conversation

@laat
Copy link
Copy Markdown
Owner

@laat laat commented Apr 12, 2026

Summary

  • stampLoc previously assigned the same loc object reference to every node in the subtree
  • Now each node gets a shallow copy so mutating one node's loc can't affect others

This was part of #134 but got dropped by the squash merge.

Test plan

  • All 105 tests pass
  • All example workspace tests pass

laat added 5 commits April 12, 2026 17:56
Each node now gets its own {start, end} copy so a downstream consumer
mutating one node's loc cannot accidentally affect every other node
in the same stamped subtree.
Replaces 6 instances of `/** @type {AstNode} */ (/** @type {unknown} */ (x))`
with a concise `asNode(x)` helper.
The function accesses node.expression.end but the JSDoc declared the
parameter as plain AstNode. Tighten to AstNode & { expression: AstNode }
so the contract matches the actual usage.
Assert expression.end as number to satisfy TS18048, and cast node
at the call site to match the narrowed parameter type.
@laat laat merged commit f2cb630 into master Apr 12, 2026
2 checks passed
@laat laat deleted the fix/stamploc-shared-ref branch April 12, 2026 17:27
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.

1 participant