zig/test/cases/switch_prong_err_enum.zig
Andrew Kelley 46eb77dbb2 stack trace is able to figure out compilation unit
each address is contained within

also fix a bug having to do with codegen for enum value
initialization expressions
2016-09-23 02:00:23 -04:00

30 lines
529 B
Zig

const assert = @import("std").debug.assert;
var read_count: u64 = 0;
fn readOnce() -> %u64 {
read_count += 1;
return read_count;
}
error InvalidDebugInfo;
enum FormValue {
Address: u64,
Other: bool,
}
#static_eval_enable(false)
fn doThing(form_id: u64) -> %FormValue {
return switch (form_id) {
17 => FormValue.Address { %return readOnce() },
else => error.InvalidDebugInfo,
}
}
#attribute("test")
fn switchProngReturnsErrorEnum() {
%%doThing(17);
assert(read_count == 1);
}