aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/error.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2022-10-05 01:21:11 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2022-10-25 05:11:28 -0400
commitc8d0e71de6c0e59b8f103526204b990fafe41f54 (patch)
treef8d46324b2b3970e12838418e17a4570a5d9e7fd /test/behavior/error.zig
parentab024d3524f60c691221f6c838d6fe340c7c7cd7 (diff)
downloadzig-c8d0e71de6c0e59b8f103526204b990fafe41f54.tar.gz
zig-c8d0e71de6c0e59b8f103526204b990fafe41f54.zip
c: fix mangling of error names
Closes #12751
Diffstat (limited to 'test/behavior/error.zig')
-rw-r--r--test/behavior/error.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig
index 6b64a0dc01..7fb125ab2a 100644
--- a/test/behavior/error.zig
+++ b/test/behavior/error.zig
@@ -843,3 +843,20 @@ fn non_errorable() void {
test "catch within a function that calls no errorable functions" {
non_errorable();
}
+
+test "error from comptime string" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
+
+ const name = "Weird error name!";
+ const S = struct {
+ fn foo() !void {
+ return @field(anyerror, name);
+ }
+ };
+ if (S.foo()) unreachable else |err| {
+ try expect(mem.eql(u8, name, @errorName(err)));
+ }
+}