diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-11-08 16:48:12 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-11-11 17:59:53 +0200 |
| commit | 89e8bb409a6b3dd47f9d1e1ab6e2abc5fb0ef746 (patch) | |
| tree | 2e7c12b7874620e757607ca69a7581585adb3dfc /test/cases/compile_errors | |
| parent | 2897641fb95a614ae61a444e43a0555804701910 (diff) | |
| download | zig-89e8bb409a6b3dd47f9d1e1ab6e2abc5fb0ef746.tar.gz zig-89e8bb409a6b3dd47f9d1e1ab6e2abc5fb0ef746.zip | |
AstGen: use `condbr_inline` if force_comptime is set
The `finishThenElseBlock` would correctly use `break_inline`
which would cause Sema to use `addRuntimeBreak` instead of
doing the branch at comptime.
Diffstat (limited to 'test/cases/compile_errors')
| -rw-r--r-- | test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig b/test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig new file mode 100644 index 0000000000..92e9620c99 --- /dev/null +++ b/test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig @@ -0,0 +1,22 @@ +pub export fn entry1() void { + var x: u32 = 3; + _ = @shuffle(u32, [_]u32{0}, @splat(1, @as(u32, 0)), [_]i8{ + if (x > 1) 1 else -1, + }); +} + +pub export fn entry2() void { + var y: ?i8 = -1; + _ = @shuffle(u32, [_]u32{0}, @splat(1, @as(u32, 0)), [_]i8{ + y orelse 1, + }); +} + +// error +// backend=stage2 +// target=native +// +// :4:15: error: unable to resolve comptime value +// :4:15: note: condition in comptime branch must be comptime-known +// :11:11: error: unable to resolve comptime value +// :11:11: note: condition in comptime branch must be comptime-known |
