Skip to content

fix: plain parallel blocks take the replace-tree's duplicate semantics - #17

Merged
ronaldtse merged 1 commit into
mainfrom
fix/plain-parallel-duplicate-semantics
Oct 1, 2026
Merged

ronaldtse merged 1 commit into
mainfrom
fix/plain-parallel-duplicate-semantics

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Two selection regimes, both measured against Ruby:

  • An all-plain parallel block compiles to a replace tree, where a later duplicate from overwrites an earlier one — masm-mon lists sub "i" "й" … sub "i" "и" precisely so the last wins (measured with a synthetic duplicate map: i → и, ab → Y).
  • A block containing guards, or any rule whose from or result holds a boundary-like token (Ruby raises "Can't use boundary in a par context", found at child 65 of bgnpcgn-bal's parallel), falls back to the megaregexp, where the earliest equal-key rule wins — bal's و → o, not the later w.

The engine now drops every duplicate plain pattern except the last when the block is par-safe (expr_is_par_safe), and keeps index order otherwise.

Direct corpus sweep: 46 failures / 14 maps → 35 / 13 — masm-mon (11 examples) fully healed, bal restored. Suite 46 passed / 1 xpassed.

Measured against Ruby: an all-plain parallel block compiles to a
replace tree where a later duplicate from overwrites an earlier one —
masm-mon lists sub "i" "й" ... sub "i" "и" precisely so the last
wins. A block containing guards, or any rule whose from or result
holds a boundary-like token (Ruby: "Can't use boundary in a par
context"), falls back to the megaregexp, where the earliest
equal-key rule wins — bgnpcgn-bal's و -> o, not the later w.

The engine now drops every duplicate plain pattern except the last
when the block is par-safe, and keeps index order otherwise.

Direct corpus sweep: 46 failures / 14 maps -> 35 / 13 — masm-mon
(11) fully healed, bal restored.
@ronaldtse
ronaldtse merged commit a218ae1 into main Oct 1, 2026
6 checks passed
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