aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-06-03 15:24:58 +0300
committerVeikka Tuominen <git@vexu.eu>2022-06-03 15:24:58 +0300
commit019537cb2a447fc28365685e71d323092e1830b0 (patch)
tree0a82f3a9b151ed2072f94383690e4eec4f561527 /src
parent8f45e81c840c79097850bb87bbee1303e6d87dd4 (diff)
downloadzig-019537cb2a447fc28365685e71d323092e1830b0.tar.gz
zig-019537cb2a447fc28365685e71d323092e1830b0.zip
Sema: `@sizeOf` function should give an error
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig2
-rw-r--r--src/type.zig12
2 files changed, 11 insertions, 3 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index e56f5f1e03..074a102c95 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -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,
diff --git a/src/type.zig b/src/type.zig
index a1adec491d..ee669df620 100644
--- a/src/type.zig
+++ b/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 => {