e87985e879
ci / build (ubuntu) (push) Has been cancelled
ci / unit + fmt (push) Has been cancelled
ci / examples (push) Has been cancelled
ci / goldens + tools (push) Has been cancelled
ci / apps (push) Has been cancelled
ci / selfhost smoke (push) Has been cancelled
ci / macos smoke (push) Has been cancelled
ci / windows smoke (push) Has been cancelled
ci / CI gate (push) Has been cancelled
selfhost-loop / bootstrap determinism (push) Has been cancelled
Desugar `is` to tag/value equality in bootstrap and selfhost so LIR no longer drops hIs as false. Resolve monomorphized Result/Option type names for `?` (_Tag/_Data). Call bux_exit(1) after Unwrap panic messages. Add is_operator example and document follow-up fixes.
41 lines
751 B
Plaintext
41 lines
751 B
Plaintext
// is_operator.bux — `expr is Variant` for simple and algebraic enums
|
|
import Std::Io::{PrintLine, PrintInt};
|
|
|
|
enum Color {
|
|
Red,
|
|
Green,
|
|
Blue,
|
|
}
|
|
|
|
enum Box {
|
|
Val(int),
|
|
Empty,
|
|
}
|
|
|
|
func Main() -> int {
|
|
let c: Color = Color { tag: Color_Red };
|
|
if c is Red {
|
|
PrintLine("color-red");
|
|
}
|
|
if c is Blue {
|
|
PrintLine("color-blue-unexpected");
|
|
} else {
|
|
PrintLine("color-not-blue");
|
|
}
|
|
|
|
let b: Box = Box { tag: Box_Val };
|
|
b.data.Val_0 = 42;
|
|
if b is Val {
|
|
Print("box-val=");
|
|
PrintInt(b.data.Val_0 as int64);
|
|
PrintLine("");
|
|
}
|
|
if b is Empty {
|
|
PrintLine("box-empty-unexpected");
|
|
} else {
|
|
PrintLine("box-not-empty");
|
|
}
|
|
|
|
return 0;
|
|
}
|