Skip to content

Divergence: ruby miscompiles alias bodies of the form alias = maybe(...) — rule silently never fires (fuzz, 52 cases) #292

Closed

Description

@ronaldtse

Summary

When a maybe(...) expression is the body of an alias, ruby miscompiles the alias so the rule never matches — silently. The same map transliterates correctly on ts, py, and rs.

Found by the WO20 differential fuzz campaign (#284): 52 of 1600 cases, all one root cause.

Minimal repro (10 lines)

system "T:fz-em5:1" {
  aliases {
    a_chain = maybe(any(["x", "y", "z"]) + any("1".."3"))
  }
  stage main {
    sequence {
      sub a_chain "R"
    }
  }
}

Input abc (the rule's from matches empty via maybe, so R inserts at every boundary):

runtime output for abc
ruby (origin/main 4c47eb5) abc — unchanged; the rule silently never fires
ts (origin/main b74cfda) RaRbRcR
py (origin/main c6ae457) RaRbRcR
rs (release 0.3.2) RaRbRcR

Why this looks like a ruby-only miscompile

  • sub maybe("k") "R" directly in from: all four agree (RaRbRcR).
  • alias = maybe("k"), sub alias "R": all four agree.
  • alias = maybe(x + y) (maybe at the TOP LEVEL of an alias body): only ruby diverges — the maybe-ness is lost and the compiled rule never matches, with no error anywhere.

Same failure via chains: a1 = any(...); a2 = a1 + any("1".."3"); a3 = maybe(a2); sub a3 "R" → ruby abc, others RaRbRcR.

Classification

Divergence (silent wrong output, ruby side wrong per the majority + the direct-form agreement). Owner decision needed on whether maybe-at-alias-body-top is legal ISC; if legal, ruby's expansion is wrong; if illegal, all four should reject at parse — today three accept and execute it consistently, ruby silently drops the rule.

Filed here (maps) per the WO20 rule: cross-runtime divergences are filed in maps referencing all four runtimes.ruby evidence above; ts/py/rs behavior is the consistent reference.

Activity

  1. added
    divergence
    on Nov 16, 2026
  2. ronaldtse commented on Nov 21, 2026

    @ronaldtse
    ContributorAuthor

    Verified closed — fix set complete

    Root cause (ruby only): the compiler wrapped a Maybe/Some/MaybeSome over a multi-atom alias body by appending the optionality suffix to the body's LAST atom instead of the whole body — maybe(any([x,y,z]) + any("1".."3")) built (?:x|y|z)[1-3]?, so alias = maybe(...) rules never matched, silently. ts/py/rs were always correct.

    Fix: interscript/interscript-ruby#867 (fc75488), shipped in ruby v3.7.3 — the wrap condition was inverted; only a single-character String body is its own atomic unit. Regression-pinned by spec/interscript/isc/fuzz_findings_spec.rb + the alias-maybe fixture.

    Re-verified on fresh origin/main trees today (2026-11-21), all four runtimes through the campaign's own drivers:

    input ruby ts py rs
    abc (direct repro, maybe at alias-body top) RaRbRcR RaRbRcR RaRbRcR RaRbRcR
    y (real match) RyR RyR RyR RyR
    abc (chain form: a1 = any(...); a2 = a1 + any; a3 = maybe(a2)) RaRbRcR RaRbRcR RaRbRcR RaRbRcR

    Both the issue's minimal repro and the chained-alias variant agree 4/4. The legality question the issue raised (whether maybe-at-alias-body-top is legal ISC) is settled by behavior: it is legal, all four execute it identically.

    Closing as complete. Related open closeout: #294 (contract posted, ruby/ts legs in review), #293/#295 (py leg in review, interscript/interscript-py#46).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    divergence

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions