Sema: coerce zero-bit generic args are coerced properly

Closes #13307
This commit is contained in:
Veikka Tuominen 2022-10-27 13:40:20 +03:00
parent b937a04560
commit 648d34d8ea
2 changed files with 12 additions and 0 deletions

View File

@ -6738,6 +6738,8 @@ fn analyzeGenericCallArg(
try sema.queueFullTypeResolution(param_ty);
runtime_args[runtime_i.*] = casted_arg;
runtime_i.* += 1;
} else if (try sema.typeHasOnePossibleValue(block, arg_src, comptime_arg.ty)) |_| {
_ = try sema.coerce(block, comptime_arg.ty, uncasted_arg, arg_src);
}
}

View File

@ -0,0 +1,10 @@
fn bar(a: anytype, _: @TypeOf(a)) void {}
pub export fn entry() void {
bar(@as(u0, 0), "fooo");
}
// error
// backend=stage2
// target=native
//
// :3:21: error: expected type 'u0', found '*const [4:0]u8'