Sema: avoid generic parameter error in nested function type
Related to cd1833044a
Closes #12945
This commit is contained in:
@@ -8180,7 +8180,7 @@ fn analyzeParameter(
|
||||
if (param.is_comptime and !Type.fnCallingConventionAllowsZigTypes(cc)) {
|
||||
return sema.fail(block, param_src, "comptime parameters not allowed in function with calling convention '{s}'", .{@tagName(cc)});
|
||||
}
|
||||
if (this_generic and !Type.fnCallingConventionAllowsZigTypes(cc)) {
|
||||
if (this_generic and !sema.no_partial_func_ty and !Type.fnCallingConventionAllowsZigTypes(cc)) {
|
||||
return sema.fail(block, param_src, "generic parameters not allowed in function with calling convention '{s}'", .{@tagName(cc)});
|
||||
}
|
||||
if (!param.ty.isValidParamType()) {
|
||||
@@ -8196,7 +8196,7 @@ fn analyzeParameter(
|
||||
};
|
||||
return sema.failWithOwnedErrorMsg(msg);
|
||||
}
|
||||
if (!Type.fnCallingConventionAllowsZigTypes(cc) and !try sema.validateExternType(block, param_src, param.ty, .param_ty)) {
|
||||
if (!this_generic and !Type.fnCallingConventionAllowsZigTypes(cc) and !try sema.validateExternType(block, param_src, param.ty, .param_ty)) {
|
||||
const msg = msg: {
|
||||
const msg = try sema.errMsg(block, param_src, "parameter of type '{}' not allowed in function with calling convention '{s}'", .{
|
||||
param.ty.fmt(sema.mod), @tagName(cc),
|
||||
|
||||
@@ -96,6 +96,7 @@ test {
|
||||
_ = @import("behavior/bugs/12885.zig");
|
||||
_ = @import("behavior/bugs/12911.zig");
|
||||
_ = @import("behavior/bugs/12928.zig");
|
||||
_ = @import("behavior/bugs/12945.zig");
|
||||
_ = @import("behavior/byteswap.zig");
|
||||
_ = @import("behavior/byval_arg_var.zig");
|
||||
_ = @import("behavior/call.zig");
|
||||
|
||||
13
test/behavior/bugs/12945.zig
Normal file
13
test/behavior/bugs/12945.zig
Normal file
@@ -0,0 +1,13 @@
|
||||
const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
fn A(
|
||||
comptime T: type,
|
||||
comptime destroycb: ?*const fn (?*T) callconv(.C) void,
|
||||
) !void {
|
||||
try expect(destroycb == null);
|
||||
}
|
||||
|
||||
test {
|
||||
try A(u32, null);
|
||||
}
|
||||
Reference in New Issue
Block a user