Commit 8b1780d939
Changed files (2)
src
test
cases
compile_errors
src/Sema.zig
@@ -9005,7 +9005,7 @@ fn zirParam(
else => |e| return e,
} or comptime_syntax;
if (sema.inst_map.get(inst)) |arg| {
- if (is_comptime) {
+ if (is_comptime and sema.preallocated_new_func != null) {
// We have a comptime value for this parameter so it should be elided from the
// function type of the function instruction in this block.
const coerced_arg = try sema.coerce(block, param_ty, arg, src);
test/cases/compile_errors/nested_generic_function_param_type_mismatch.zig
@@ -0,0 +1,24 @@
+pub fn sort(
+ comptime T: type,
+ items: []T,
+ context: anytype,
+ lessThan: *const fn (context: @TypeOf(context), lhs: T, rhs: T) u32,
+) void {
+ _ = items;
+ _ = lessThan;
+}
+fn foo(_: void, _: u8, _: u8) u32 {
+ return 0;
+}
+pub export fn entry() void {
+ var items = [_]u8{ 3, 5, 7, 2, 6, 9, 4 };
+ sort(u8, &items, void, foo);
+}
+
+// error
+// backend=llvm
+// target=native
+//
+// :15:28: error: expected type '*const fn(comptime type, u8, u8) u32', found '*const fn(void, u8, u8) u32'
+// :15:28: note: pointer type child 'fn(void, u8, u8) u32' cannot cast into pointer type child 'fn(comptime type, u8, u8) u32'
+// :15:28: note: non-generic function cannot cast into a generic function