fix missing implicit cast in return instruction

This commit is contained in:
Vexu
2019-11-19 17:29:43 +02:00
committed by Andrew Kelley
parent 0b63573674
commit 4d9318cee0
2 changed files with 31 additions and 10 deletions

View File

@@ -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 {