diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-09-23 02:00:23 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-09-23 02:00:23 -0400 |
| commit | 46eb77dbb200756b96bfae4c5166397fefba66d0 (patch) | |
| tree | 618f0117563dfabbe0e4253f6fa817e526b5a64c /test/cases/switch_prong_err_enum.zig | |
| parent | 4b902b44a244e29106637f9777aa71b1cd4c22d2 (diff) | |
| download | zig-46eb77dbb200756b96bfae4c5166397fefba66d0.tar.gz zig-46eb77dbb200756b96bfae4c5166397fefba66d0.zip | |
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
Diffstat (limited to 'test/cases/switch_prong_err_enum.zig')
| -rw-r--r-- | test/cases/switch_prong_err_enum.zig | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/cases/switch_prong_err_enum.zig b/test/cases/switch_prong_err_enum.zig new file mode 100644 index 0000000000..cb8c864357 --- /dev/null +++ b/test/cases/switch_prong_err_enum.zig @@ -0,0 +1,29 @@ +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); +} |
