Files
ww/test/wcc/data/r929_match_4arm_mixed_kinds/case.ww

28 lines
841 B
Plaintext

//ww:run
package main;
// migrated from test/wcc/929_match_4arm_cross_module_run.c: mixed variant kinds (i32|str|rune|u8) — the shadowed-resolution fix is not shape-specific.
package a;
export fn next(k: i32) (i32 | str | rune | u8) = {
if (k == 0) { return 7; };
if (k == 1) { return "hi"; };
if (k == 2) { return 0x45u32: rune; };
return 9u8;
};
package b;
import a;
fn next(k: i32) i32 = {
match (a.next(k)) {
case let n: i32 => return 100 + n;
case let s: str => return 200i32 + (s.len: i32);
case let r: rune => return 300i32 + (r: i32);
case let c: u8 => return 400i32 + (c: i32);
};
};
export fn main() i32 = {
if (next(0) != 107) { return 11; };
if (next(1) != 202) { return 12; };
if (next(2) != 369) { return 13; };
if (next(3) != 409) { return 14; };
return 0;
};