mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
23 lines
517 B
Plaintext
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
|
|
} |