authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-14 16:24:43-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-14 16:24:43-05:00
log9fa35adbd4772f55e3e43dd7cc69823415661153
tree3b678df3295a336401543d072d5d7e01ba26aed7
parent629f134d3805f99938f59a6ee7f6598591abc9d7

fix sometimes not type checking function parameters

closes #774 regression introduced in cfb2c676925d77887e46631dcafa783e6c65e61d

2 files changed, 14 insertions(+), 1 deletions(-)

src/ir.cpp+1-1
......@@ -6727,8 +6727,8 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry
67276727 result.id = ConstCastResultIdFnReturnType;
67286728 result.data.return_type = allocate_nonzero<ConstCastOnly>(1);
67296729 *result.data.return_type = child;
6730 return result;
67306731 }
6731 return result;
67326732 }
67336733 if (expected_type->data.fn.fn_type_id.param_count != actual_type->data.fn.fn_type_id.param_count) {
67346734 result.id = ConstCastResultIdFnArgCount;
test/compile_errors.zig+13
......@@ -1,6 +1,19 @@
11const tests = @import("tests.zig");
22
33pub fn addCases(cases: &tests.CompileErrorContext) void {
4 cases.add("type checking function pointers",
5 \\fn a(b: fn (&const u8) void) void {
6 \\ b('a');
7 \\}
8 \\fn c(d: u8) void {
9 \\ @import("std").debug.warn("{c}\n", d);
10 \\}
11 \\export fn entry() void {
12 \\ a(c);
13 \\}
14 ,
15 ".tmp_source.zig:8:7: error: expected type 'fn(&const u8) void', found 'fn(u8) void'");
16
417 cases.add("no else prong on switch on global error set",
518 \\export fn entry() void {
619 \\ foo(error.A);