diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-06-04 12:20:28 +0300 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-06-06 13:11:50 -0700 |
| commit | a040ccb42f1b34ba612c975b7030ccdcbb3f8086 (patch) | |
| tree | b25a7f6f1bdf32e234e928914f14bfd36c5de97b /test/behavior/basic.zig | |
| parent | 33826a6a2e035d2a2be65314ed80a6b7abaf7f12 (diff) | |
| download | zig-a040ccb42f1b34ba612c975b7030ccdcbb3f8086.tar.gz zig-a040ccb42f1b34ba612c975b7030ccdcbb3f8086.zip | |
Sema: fix coerce result ptr outside of functions
Diffstat (limited to 'test/behavior/basic.zig')
| -rw-r--r-- | test/behavior/basic.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index 3129091091..b45f5a0b49 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -1,5 +1,6 @@ const std = @import("std"); const builtin = @import("builtin"); +const assert = std.debug.assert; const mem = std.mem; const expect = std.testing.expect; const expectEqualStrings = std.testing.expectEqualStrings; @@ -1053,3 +1054,11 @@ test "const alloc with comptime known initializer is made comptime known" { if (u.a == 0) @compileError("bad"); } } + +comptime { + // coerce result ptr outside a function + const S = struct { a: comptime_int }; + var s: S = undefined; + s = S{ .a = 1 }; + assert(s.a == 1); +} |
