| author | |
| committer | |
| log | 8b1780d9396aa7bd919f2ec5e003f981bbce07d5 |
| tree | d8b7e2c514331dfb6b777bbc449bcc68dd3d754a |
| parent | ad259736e2200e93400e4f09916551ae65ca56ad |
Closes #141642 files changed, 25 insertions(+), 1 deletions(-)
src/Sema.zig+1-1| ... | ... | @@ -9005,7 +9005,7 @@ fn zirParam( |
| 9005 | 9005 | else => |e| return e, |
| 9006 | 9006 | } or comptime_syntax; |
| 9007 | 9007 | if (sema.inst_map.get(inst)) |arg| { |
| 9008 | if (is_comptime) { | |
| 9008 | if (is_comptime and sema.preallocated_new_func != null) { | |
| 9009 | 9009 | // We have a comptime value for this parameter so it should be elided from the |
| 9010 | 9010 | // function type of the function instruction in this block. |
| 9011 | 9011 | const coerced_arg = try sema.coerce(block, param_ty, arg, src); |
test/cases/compile_errors/nested_generic_function_param_type_mismatch.zig created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | pub fn sort( | |
| 2 | comptime T: type, | |
| 3 | items: []T, | |
| 4 | context: anytype, | |
| 5 | lessThan: *const fn (context: @TypeOf(context), lhs: T, rhs: T) u32, | |
| 6 | ) void { | |
| 7 | _ = items; | |
| 8 | _ = lessThan; | |
| 9 | } | |
| 10 | fn foo(_: void, _: u8, _: u8) u32 { | |
| 11 | return 0; | |
| 12 | } | |
| 13 | pub export fn entry() void { | |
| 14 | var items = [_]u8{ 3, 5, 7, 2, 6, 9, 4 }; | |
| 15 | sort(u8, &items, void, foo); | |
| 16 | } | |
| 17 | ||
| 18 | // error | |
| 19 | // backend=llvm | |
| 20 | // target=native | |
| 21 | // | |
| 22 | // :15:28: error: expected type '*const fn(comptime type, u8, u8) u32', found '*const fn(void, u8, u8) u32' | |
| 23 | // :15:28: note: pointer type child 'fn(void, u8, u8) u32' cannot cast into pointer type child 'fn(comptime type, u8, u8) u32' | |
| 24 | // :15:28: note: non-generic function cannot cast into a generic function |