diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-06-24 21:53:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-24 21:53:59 -0700 |
| commit | a31ba25a3dc7db037a29938fb4f040896edfdba9 (patch) | |
| tree | 52bf4d79558a5fa54856f2b17dba1fbd11ea73a6 /test | |
| parent | 146b79af153bbd5dafda0ba12a040385c7fc58f8 (diff) | |
| parent | d3fed1a87ee20e5c041f18f9768ef5c9be96e69e (diff) | |
| download | zig-a31ba25a3dc7db037a29938fb4f040896edfdba9.tar.gz zig-a31ba25a3dc7db037a29938fb4f040896edfdba9.zip | |
Merge pull request #16188 from kcbanner/fix_cbe_airErrUnionPayloadPtrSet
cbe: fix crash caused by calling `mod.intValue` on `type_inferred_error_set`
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/error.zig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig index 06062ac66c..1c4450a07f 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -921,3 +921,20 @@ test "optional error set return type" { try expect(null == S.foo(true)); try expect(E.A == S.foo(false).?); } + +test "returning an error union containing a type with no runtime bits" { + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; + + const ZeroByteType = struct { + foo: void, + + pub fn init() !@This() { + return .{ .foo = {} }; + } + }; + + var zero_byte: ZeroByteType = undefined; + (&zero_byte).* = try ZeroByteType.init(); +} |
