fix(core): drop NUL-byte separator from the when-clause regex tokenizer#53
Open
thorwhalen wants to merge 1 commit into
Open
fix(core): drop NUL-byte separator from the when-clause regex tokenizer#53thorwhalen wants to merge 1 commit into
thorwhalen wants to merge 1 commit into
Conversation
…izer The regex-literal token packed `pattern + <NUL> + flags` into one string and split on that same NUL downstream. Self-consistent (tests passed), but it made when.ts and the built dist binary to git (no diff/blame rendering) and was fragile — a naive NUL->space "cleanup" would break any regex pattern containing a space (e.g. /foo bar/). Store `pattern` and `flags` as distinct Token fields (no separator at all). Behavior-identical for every input; adds a regression test for a space-containing pattern, previously only guarded by the invisible NUL and never tested. Discovered during the v1.14-v1.18 pre-wiring review (#51). No public API or runtime-behavior change. Claude-Session: https://claude.ai/code/session_01A1PykLHv2BjQRQhspjvPWy
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.
Why
Surfaced during the v1.14–v1.18 pre-wiring review (#51) via a byte-level scan:
packages/core/src/when.tsused a NUL byte (\x00) as the regexpattern | flagsseparator — the tokenizer joinedpattern + <NUL> + flags(was line 180) and the parser split on the same NUL (was line 348).It was self-consistent (all tests passed), but:
dist— were binary to git. No diff, blame, or PR-review rendering forwhen.ts./foo bar/→split(' ')mangles it). That exact case was never tested — it worked only because the separator was a NUL.What
The regex token now carries
patternandflagsas distinctTokenfields — no separator at all. This is behavior-identical for every input (the NUL was correctly doing its job; this just removes the fragile packing) and removes the non-printable byte from source and dist.Tokengains an optionalflags?: string(regex-only).value: pattern, flagsinstead ofvalue: pattern + <NUL> + flags.t.value/t.flagsinstead oft.value.split(<NUL>)./foo bar/,/foo bar/i).Verification
when.tsis now valid UTF-8 (0 NUL bytes); builtdistverified NUL-free.when.test+1).acturecore patch bump (changeset included). No public API or runtime-behavior change.https://claude.ai/code/session_01A1PykLHv2BjQRQhspjvPWy