Sema: @sizeOf function should give an error

This commit is contained in:
Veikka Tuominen 2022-06-03 15:24:58 +03:00
parent 8f45e81c84
commit 019537cb2a
2 changed files with 11 additions and 3 deletions

View File

@ -11547,7 +11547,7 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
const ty = try sema.resolveType(block, operand_src, inst_data.operand);
switch (ty.zigTypeTag()) {
.Fn => unreachable,
.Fn,
.NoReturn,
.Undefined,
.Null,

View File

@ -2035,7 +2035,11 @@ pub const Type = extern union {
try writer.writeAll("fn(");
for (fn_info.param_types) |param_ty, i| {
if (i != 0) try writer.writeAll(", ");
try print(param_ty, writer, mod);
if (param_ty.tag() == .generic_poison) {
try writer.writeAll("anytype");
} else {
try print(param_ty, writer, mod);
}
}
if (fn_info.is_var_args) {
if (fn_info.param_types.len != 0) {
@ -2052,7 +2056,11 @@ pub const Type = extern union {
if (fn_info.alignment != 0) {
try writer.print("align({d}) ", .{fn_info.alignment});
}
try print(fn_info.return_type, writer, mod);
if (fn_info.return_type.tag() == .generic_poison) {
try writer.writeAll("anytype");
} else {
try print(fn_info.return_type, writer, mod);
}
},
.error_union => {