mirror of
https://github.com/ziglang/zig.git
synced 2026-02-17 14:59:14 +00:00
fix sometimes not type checking function parameters
closes #774 regression introduced in cfb2c676925d77887e46631dcafa783e6c65e61d
This commit is contained in:
parent
629f134d38
commit
9fa35adbd4
@ -6727,8 +6727,8 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry
|
||||
result.id = ConstCastResultIdFnReturnType;
|
||||
result.data.return_type = allocate_nonzero<ConstCastOnly>(1);
|
||||
*result.data.return_type = child;
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (expected_type->data.fn.fn_type_id.param_count != actual_type->data.fn.fn_type_id.param_count) {
|
||||
result.id = ConstCastResultIdFnArgCount;
|
||||
|
||||
@ -1,6 +1,19 @@
|
||||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: &tests.CompileErrorContext) void {
|
||||
cases.add("type checking function pointers",
|
||||
\\fn a(b: fn (&const u8) void) void {
|
||||
\\ b('a');
|
||||
\\}
|
||||
\\fn c(d: u8) void {
|
||||
\\ @import("std").debug.warn("{c}\n", d);
|
||||
\\}
|
||||
\\export fn entry() void {
|
||||
\\ a(c);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:8:7: error: expected type 'fn(&const u8) void', found 'fn(u8) void'");
|
||||
|
||||
cases.add("no else prong on switch on global error set",
|
||||
\\export fn entry() void {
|
||||
\\ foo(error.A);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user