mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
Sema: @sizeOf function should give an error
This commit is contained in:
parent
8f45e81c84
commit
019537cb2a
@ -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,
|
||||
|
||||
12
src/type.zig
12
src/type.zig
@ -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 => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user