Files
c3c/test/test_suite/errors/rethrow_macro_cost_err.c3t
Christoffer Lerno cdabe8fd9e - Create optional with ~ instead of ?. return io::EOF?; becomes return io::EOF~.
- Deprecated use of `?` to create optional.
2026-01-20 16:10:28 +01:00

23 lines
517 B
Plaintext

module testing_branch;
import std::io;
faultdef OH_NO;
const C = 1;
fn void main() => do_thing()!!;
fn void? do_thing()
{
int* a_value = mem::alloc_array(int, 4);
// Change 'C' below to any integer value and the assert goes away.
*(int128*)a_value = may_fault(int128, "-123", C)!;
io::printfn("Value: %d", *a_value);
}
macro may_fault($ArgType, something, $incoming)
{
$switch $incoming:
$case 1: return OH_NO~;
$default: return something.to_integer($ArgType);
$endswitch
}