fix(parser): capture tapped-and-attacking when trailed by where-X clause (closes #2379) - #2807
Conversation
…ause (CR 508.4 + CR 107.3)
Tokens created with "that are tapped and attacking, where X is …" (e.g.
Anim Pakal, Thousandth Moon) were silently ignoring the entering-tapped
and entering-attacking flags.
Root cause: `parse_token_description`'s `attacking_clause` combinator
used `eof` as the only allowed terminator after the attacking phrase.
When a variable-count binding (", where X is …") followed, the eof
check failed at every scan position and `tapped`/`enters_attacking`
both stayed false.
Fix: accept `, where ` as a second valid terminator. The where-
expression is also saved before the text is truncated at the clause
boundary so the X-binding step can still resolve the variable count.
Covers the full class of token effects that combine an entry modifier
with a variable-count rebind.
There was a problem hiding this comment.
Code Review
This pull request updates the token parser in crates/engine/src/parser/oracle_effect/token.rs to correctly handle token creation clauses that specify entering tapped and/or attacking followed by a variable expression (e.g., ', where X is...'). It allows the attacking clause parser to terminate on either EOF or ', where ', extracts and saves the trailing expression before truncation, and falls back to it when resolving the variable count. A unit test has been added to verify this behavior. There are no review comments, and we have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Review: PR #2807 — tapped-and-attacking with trailing where-X clauseVerdict: APPROVE. Correct seam, idiomatic, genuinely class-general, and the test is discriminating. The bug is real on Correct seamThe fix lives in (a) Combinator compliance — PASSThe terminator widening is a proper let (i, _) = alt((value((), nom::combinator::eof), value((), tag(", where ")))).parse(i)?; // token.rs:306
(b)
|
Review: PR #2807 — capture tapped-and-attacking when trailed by where-X clauseVERDICT: approve Independent pass (review-impl lenses). Confirms the prior review and adds traced evidence. Correct seam — PASSFix lives in Bug is live on main / fix reachable — PASS
Combinator + no-regression trace — PASS
Test discrimination — PASS
CR — PASS
Note (non-blocking, pre-existing)LOW: |
matthewevans
left a comment
There was a problem hiding this comment.
Maintainer sign-off: class-general nom terminator widening at the single token-description authority; bug live on main (#2379), discriminating unit test; Gemini clean + two independent review-impl approvals; CI green.
Fixes #2379
Root cause
parse_token_descriptionuses a scan loop to find the"that are tapped and attacking"suffix in the token text. The loop required the attacking phrase to be followed by EOF. When a variable-count binding (", where X is …") trails the clause — as in Anim Pakal's— the EOF check failed at every byte position and both
tappedandenters_attackingstayedfalse.Fix
Two minimal changes to
parse_token_descriptioninoracle_effect/token.rs:Extend the terminator check — the attacking-clause combinator now accepts
, whereas a valid terminator in addition to EOF (CR 107.3: where-clause binds a variable; it does not affect entry state).Preserve the where-expression — after the attacking clause is detected the text is truncated at
pos, stripping the trailing where-clause from whatsuffixsees.saved_where_x_exprcaptures the expression from the pre-truncation text and is used as a fallback in the X-binding step, keeping the variable count correctly resolved.Coverage
Covers the full class of token-creation effects that combine an entry modifier (
tapped and attacking) with a variable-count rebind (where X is …). Cards besides Anim Pakal that follow this pattern include any future cards using the same Oracle grammar.Tests
tapped_and_attacking_with_trailing_where_x_clause— verifiestapped=true,enters_attacking=true, andcount=CountersOn(Source, P1P1)for the Anim Pakal token text.plural_that_are_tapped_and_attacking_suffix_strips(Leonin Warleader) — still passes, eof path unaffected.