From 4d9318cee075fbc662cb4e20a74c7f887c3a3da4 Mon Sep 17 00:00:00 2001 From: Vexu <15308111+Vexu@users.noreply.github.com> Date: Tue, 19 Nov 2019 17:29:43 +0200 Subject: fix missing implicit cast in return instruction --- test/compile_errors.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/compile_errors.zig') diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 04355261f9..9e47d2a458 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -12,6 +12,27 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { "tmp.zig:3:5: error: switch must handle all possibilities", ); + cases.add( + "incorrect return type", + \\ pub export fn entry() void{ + \\ _ = foo(); + \\ } + \\ const A = struct { + \\ a: u32, + \\ }; + \\ fn foo() A { + \\ return bar(); + \\ } + \\ const B = struct { + \\ a: u32, + \\ }; + \\ fn bar() B { + \\ unreachable; + \\ } + , + "tmp.zig:8:16: error: expected type 'A', found 'B'", + ); + cases.add( "regression test #2980: base type u32 is not type checked properly when assigning a value within a struct", \\const Foo = struct { -- cgit v1.2.3