authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-03 15:24:58+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-03 15:24:58+03:00
log019537cb2a447fc28365685e71d323092e1830b0
tree0a82f3a9b151ed2072f94383690e4eec4f561527
parent8f45e81c840c79097850bb87bbee1303e6d87dd4

Sema: `@sizeOf` function should give an error


2 files changed, 11 insertions(+), 3 deletions(-)

src/Sema.zig+1-1
...@@ -11547,7 +11547,7 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -11547,7 +11547,7 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
11547 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };11547 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
11548 const ty = try sema.resolveType(block, operand_src, inst_data.operand);11548 const ty = try sema.resolveType(block, operand_src, inst_data.operand);
11549 switch (ty.zigTypeTag()) {11549 switch (ty.zigTypeTag()) {
11550 .Fn => unreachable,11550 .Fn,
11551 .NoReturn,11551 .NoReturn,
11552 .Undefined,11552 .Undefined,
11553 .Null,11553 .Null,
src/type.zig+10-2
...@@ -2035,7 +2035,11 @@ pub const Type = extern union {...@@ -2035,7 +2035,11 @@ pub const Type = extern union {
2035 try writer.writeAll("fn(");2035 try writer.writeAll("fn(");
2036 for (fn_info.param_types) |param_ty, i| {2036 for (fn_info.param_types) |param_ty, i| {
2037 if (i != 0) try writer.writeAll(", ");2037 if (i != 0) try writer.writeAll(", ");
2038 try print(param_ty, writer, mod);2038 if (param_ty.tag() == .generic_poison) {
2039 try writer.writeAll("anytype");
2040 } else {
2041 try print(param_ty, writer, mod);
2042 }
2039 }2043 }
2040 if (fn_info.is_var_args) {2044 if (fn_info.is_var_args) {
2041 if (fn_info.param_types.len != 0) {2045 if (fn_info.param_types.len != 0) {
...@@ -2052,7 +2056,11 @@ pub const Type = extern union {...@@ -2052,7 +2056,11 @@ pub const Type = extern union {
2052 if (fn_info.alignment != 0) {2056 if (fn_info.alignment != 0) {
2053 try writer.print("align({d}) ", .{fn_info.alignment});2057 try writer.print("align({d}) ", .{fn_info.alignment});
2054 }2058 }
2055 try print(fn_info.return_type, writer, mod);2059 if (fn_info.return_type.tag() == .generic_poison) {
2060 try writer.writeAll("anytype");
2061 } else {
2062 try print(fn_info.return_type, writer, mod);
2063 }
2056 },2064 },
20572065
2058 .error_union => {2066 .error_union => {