Skip to content

docs(lath): correct replaceAtPath off-tree-path comment - #363

Open
dormouse-bot wants to merge 1 commit into
mainfrom
docs/lath-replaceatpath-comment
Open

docs(lath): correct replaceAtPath off-tree-path comment#363
dormouse-bot wants to merge 1 commit into
mainfrom
docs/lath-replaceatpath-comment

Conversation

@dormouse-bot

Copy link
Copy Markdown
Collaborator

Problem

The replaceAtPath doc comment in lib/src/lib/lath/model.ts describes the off-tree-path behavior as returning replacement:

a path that leaves the tree returns replacement unchanged from wherever the walk stopped

The code does the opposite. When the walk leaves the tree — hitting a leaf before path is exhausted (if (root.kind !== 'split') return root;) or naming a missing child (if (!child) return root;) — it returns the original subtree reached so far and never inserts replacement. A reader relying on the comment could assume replacement gets grafted on an off-tree path when in fact it is dropped.

Solution

Reword the comment to match the actual behavior: an off-tree path returns the subtree reached so far unchanged, without inserting replacement.

Testing

Documentation-only change; no test added. The behavior itself is unchanged.

Surfaced by the nightly code-quality survey.

The doc claimed an off-tree path 'returns replacement unchanged from
wherever the walk stopped', but the code returns the original subtree
reached so far and never inserts replacement (return root on a leaf hit
or missing child index). Reword to match actual behavior.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: ee2fb00
Status: ✅  Deploy successful!
Preview URL: https://6c86c347.mouseterm.pages.dev
Branch Preview URL: https://docs-lath-replaceatpath-comm.mouseterm.pages.dev

View logs

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