aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-10-25 13:40:03 -0400
committerGitHub <noreply@github.com>2021-10-25 13:40:03 -0400
commitd4bf44024a005fcd6931fd0975d78c890dedb4e6 (patch)
tree35931469836f03190a72f3b3a277279a766a4138 /test/behavior
parent3f6eef22e4f50c1fb80557f7e48e85d8224b6281 (diff)
parent9c5b852f9bb47e25c878cbccdaa175517ae48fc6 (diff)
downloadzig-d4bf44024a005fcd6931fd0975d78c890dedb4e6.tar.gz
zig-d4bf44024a005fcd6931fd0975d78c890dedb4e6.zip
Merge pull request #10019 from mattbork/ret-fixes
astgen.zig: fixes for error propagation `ret` and return types in `fnDecl` and `fnProtoExpr`
Diffstat (limited to 'test/behavior')
-rw-r--r--test/behavior/fn_stage1.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/behavior/fn_stage1.zig b/test/behavior/fn_stage1.zig
index 06c5d8fdb2..9368b39a46 100644
--- a/test/behavior/fn_stage1.zig
+++ b/test/behavior/fn_stage1.zig
@@ -204,3 +204,19 @@ test "function with inferred error set but returning no error" {
const return_ty = @typeInfo(@TypeOf(S.foo)).Fn.return_type.?;
try expectEqual(0, @typeInfo(@typeInfo(return_ty).ErrorUnion.error_set).ErrorSet.?.len);
}
+
+const nComplexCallconv = 100;
+fn fComplexCallconvRet(x: u32) callconv(blk: {
+ const s: struct { n: u32 } = .{ .n = nComplexCallconv };
+ break :blk switch (s.n) {
+ 0 => .C,
+ 1 => .Inline,
+ else => .Unspecified,
+ };
+}) struct { x: u32 } {
+ return .{ .x = x * x };
+}
+
+test "function with complex callconv and return type expressions" {
+ try expect(fComplexCallconvRet(3).x == 9);
+}