Issue #1132: An or-pattern binding of a variant text field filled from literals stays &'static str (rustc: mismatched types on push into Vec[String])

Open and answer this issue on GitHub.

ready · opened 2026-11-01 · updated 2026-11-01 · 0 comments

Found by b30 (#1127’s fix, docs/briefs/bugs/b30-1127-narrowed-field-or-pattern.md.report.md); the binary before b30 has it too. Probe checked by the architect on target/fast/nikaia at f41c3f4a.

enum Pair { B(String, i64), D(String, i64), C }

fn main() {
    let pairs = [Pair::B("y", 3), Pair::D("z", 4), Pair::C]
    let mut out: Vec[String] = []
    for pair in pairs {
        let s = match pair { Pair::B(s, _) | Pair::D(s, _) => s.clone(), else => continue }
        out.push(s)
    }
    println(out.len())
}

Expected 2. Got rustc’s Mismatched types at out.push(s): the variants’ String field, filled only from literals, lowers as &'static str, and the binding of an or-pattern does not carry its flow into owned text. With a single arm Pair::B(s, _) it runs (1).

Suspected location (fairly sure, from reading): crates/nikaia-std/src/tools/text_tiers.nika, bind_static_payloads has arms for MatchPattern::Tuple and MatchPattern::Named but none for MatchPattern::Or, so the names an or-pattern binds are never tied to the positions they read (late_pattern ~:3772 does walk Or).

To build

  1. Reproduce the probe (Tests:).
  2. bind_static_payloads walks each alternative of MatchPattern::Or and binds a name to every position it reads in any alternative, so a flow into owned text raises all of them (here both Pair::B.0 and Pair::D.0). Check every other match pattern in text_tiers.nika that lists Tuple/Named without Or (bind_tuple_parts, bind_some_payload) and give each the same arm, or say in Body: why it needs none.
  3. lower-std and its fixpoint.
  4. Test tests/compiler/tests/or_pattern_text_payload.nika + .stdout: the probe, and the same with a named variant B { s: String }; failing on the unfixed binary.

Commit text tiers: a name bound in an or-pattern ties every alternative's position.


Generated by Claude Code

Back to Open Issues