Skip to content

fix(runtime): fail loud on unresolved aliases and missing stages (WO18 G3/G4) - #136

Merged
ronaldtse merged 1 commit into
mainfrom
wo18-g3g4g8-ts
Nov 13, 2026
Merged

ronaldtse merged 1 commit into
mainfrom
wo18-g3g4g8-ts

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

WO18 G3/G4 from the merged four-runtime parity audit (maps
docs/parity/README.md, PR #275): the ts runtime silently corrupted
output on unresolved aliases and silently no-op'd on missing stages.
ruby raises named errors in both situations (rs too); this aligns ts.

  • G3 (src/runtime/compile-item.ts): an alias that resolves to
    nothing compiled to the EMPTY matcher (re: "", which matches at
    every string boundary), silently splicing the replacement text —
    sub unknown_alias "X", input "a" gave "XaX", "zzz" gave
    "XzXzXzX". Now raises MapLogicError "Alias <name> not found"
    (ruby's message). The parallel paths inherit the raise: literal
    expansion returns null, the block falls to the megaregexp path, and
    the compile there surfaces the same error.
  • G4 (src/runtime/interpreter.ts): requesting an absent stage
    returned the input unchanged, hiding map typos (--stage mahn
    silently "worked"). executeStage and executeStageAsync now raise
    MapLogicError with rs's message shape: stage "mahn" not found in <system code>. Missing run-target stages already raised.

API-visible change (G4): callers who relied on the missing-stage
no-op now get MapLogicError, in transliterate and
transliterateAsync alike.

Test plan

  • New test/isc/fail-loud.test.ts written first (red): unknown
    alias raised nothing; missing stage returned the input. After the
    fix: 4/4 green, including the async path.
  • Full suite: 375 passed -> 378 passed, 4 skipped (baseline run on
    the clean branch immediately before the change; no pre-existing
    failures).
  • lint (eslint), tsc --noEmit, prettier all clean.
  • Cross-grammar parse-parity harness (maps scripts/parse-parity.mjs): output byte-identical to the origin/main
    baseline run (412/435, same divergence counts) — no grammar/parser
    behavior change; no grammar files touched.
  • Probe drivers: tst-g3-unknown-alias -> MapLogicError Alias unknown_alias not found; missing stage -> MapLogicError stage "mahn" not found in T:...; tst-dir-upcase still "A".

WO18 G3/G4 from the merged four-runtime parity audit (maps
docs/parity/README.md, PR #275).

G3: an alias that resolves to nothing compiled to the empty matcher
(re: "", literal: ""), which matches at every string boundary and
silently splices the replacement text ("a" -> "XaX"). Raise
MapLogicError "Alias <name> not found" instead, mirroring ruby's
SystemConversionError and rs's load-time error. The parallel paths are
covered by the same raise: compileToLiteral/expandFromLiterals return
null, the block falls to the megaregexp path, and compileItem surfaces
the error there.

G4: requesting a stage the map doesn't have silently returned the
input, hiding map typos. Both executeStage and executeStageAsync now
raise MapLogicError "stage "<name>" not found in <system code>"
(rs's message shape). Run-target stages already raised.

API-visible change: callers who relied on the missing-stage no-op now
get MapLogicError (transliterate and transliterateAsync alike).
@ronaldtse
ronaldtse merged commit 87fed8d into main Nov 13, 2026
9 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