diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-05-18 17:01:45 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-05-20 02:47:20 -0700 |
| commit | cd04b49041200b36c5af23ac3700cbfa82f037ca (patch) | |
| tree | 415600adaea3553fd3bf3020958812672f6aa97c /test/behavior/call.zig | |
| parent | 5626bb45d24cd4a57a4f6a1c0f41ec0feb276f7b (diff) | |
| download | zig-cd04b49041200b36c5af23ac3700cbfa82f037ca.tar.gz zig-cd04b49041200b36c5af23ac3700cbfa82f037ca.zip | |
stage2: fix `@call` when used in a comptime or nosuspend block
`@call` allows specifying the modifier explicitly, however it can still
appear in a context that overrides the modifier. This commit adds flags
to the BuiltinCall ZIR encoding. Since we have unused bits I also threw
in the ensure_result_used mechanism.
I also deleted a behavior test that was checking for bound function
behavior where I think stage2 behavior is correct and stage1 behavior
is incorrect.
Diffstat (limited to 'test/behavior/call.zig')
| -rw-r--r-- | test/behavior/call.zig | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/test/behavior/call.zig b/test/behavior/call.zig index 27d0bbf1d6..0297582234 100644 --- a/test/behavior/call.zig +++ b/test/behavior/call.zig @@ -19,7 +19,11 @@ test "super basic invocations" { } test "basic invocations" { - if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_wasm) 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 + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO const foo = struct { fn foo() i32 { @@ -41,7 +45,10 @@ test "basic invocations" { } { // call of non comptime-known function - var alias_foo = foo; + var alias_foo = switch (builtin.zig_backend) { + .stage1 => foo, + else => &foo, + }; try expect(@call(.{ .modifier = .no_async }, alias_foo, .{}) == 1234); try expect(@call(.{ .modifier = .never_tail }, alias_foo, .{}) == 1234); try expect(@call(.{ .modifier = .never_inline }, alias_foo, .{}) == 1234); @@ -79,26 +86,6 @@ test "tuple parameters" { } } -test "comptime call with bound function as parameter" { - if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO - - const S = struct { - fn ReturnType(func: anytype) type { - return switch (@typeInfo(@TypeOf(func))) { - .BoundFn => |info| info, - else => unreachable, - }.return_type orelse void; - } - - fn call_me_maybe() ?i32 { - return 123; - } - }; - - var inst: S = undefined; - try expectEqual(?i32, S.ReturnType(inst.call_me_maybe)); -} - test "result location of function call argument through runtime condition and struct init" { if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
