diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-05-18 19:05:46 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-10 20:47:53 -0700 |
| commit | f21ca3da190c8c64fd99c700f0840af59792b6b2 (patch) | |
| tree | 7a2853ce05fb11ad9dc81d9252f32d601459f156 /src/Sema.zig | |
| parent | 17882162b3be5542b4e289e5ddc6535a4bb4c6b1 (diff) | |
| download | zig-f21ca3da190c8c64fd99c700f0840af59792b6b2.tar.gz zig-f21ca3da190c8c64fd99c700f0840af59792b6b2.zip | |
compiler: move `anyframe->T` to InternPool
Also I moved `anyframe` from being represented by `SimpleType` to being
represented by the `none` tag of `anyframe_type` because most code wants
to handle these two types together.
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index eb8dc5a633..c855c5e188 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -8042,9 +8042,10 @@ fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro if (true) { return sema.failWithUseOfAsync(block, inst_data.src()); } + const mod = sema.mod; const operand_src: LazySrcLoc = .{ .node_offset_anyframe_type = inst_data.src_node }; const return_type = try sema.resolveType(block, operand_src, inst_data.operand); - const anyframe_type = try Type.Tag.anyframe_T.create(sema.arena, return_type); + const anyframe_type = try mod.anyframeType(return_type); return sema.addType(anyframe_type); } @@ -31626,10 +31627,6 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { }, .error_union => return sema.resolveTypeRequiresComptime(ty.errorUnionPayload()), - .anyframe_T => { - const child_ty = ty.castTag(.anyframe_T).?.data; - return sema.resolveTypeRequiresComptime(child_ty); - }, }, else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { .int_type => false, @@ -31641,6 +31638,10 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { return sema.resolveTypeRequiresComptime(child_ty); } }, + .anyframe_type => |child| { + if (child == .none) return false; + return sema.resolveTypeRequiresComptime(child.toType()); + }, .array_type => |array_type| return sema.resolveTypeRequiresComptime(array_type.child.toType()), .vector_type => |vector_type| return sema.resolveTypeRequiresComptime(vector_type.child.toType()), .opt_type => |child| return sema.resolveTypeRequiresComptime(child.toType()), @@ -31669,7 +31670,6 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { .bool, .void, .anyerror, - .@"anyframe", .noreturn, .generic_poison, .var_args_param, @@ -33054,7 +33054,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { .error_set_merged, .error_union, .error_set_inferred, - .anyframe_T, .pointer, => return null, @@ -33083,6 +33082,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { .ptr_type, .error_union_type, .func_type, + .anyframe_type, => null, .array_type => |array_type| { @@ -33130,7 +33130,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { .anyerror, .comptime_int, .comptime_float, - .@"anyframe", .enum_literal, .atomic_order, .atomic_rmw_op, @@ -33688,10 +33687,6 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { }, .error_union => return sema.typeRequiresComptime(ty.errorUnionPayload()), - .anyframe_T => { - const child_ty = ty.castTag(.anyframe_T).?.data; - return sema.typeRequiresComptime(child_ty); - }, }, else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { .int_type => return false, @@ -33703,6 +33698,10 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { return sema.typeRequiresComptime(child_ty); } }, + .anyframe_type => |child| { + if (child == .none) return false; + return sema.typeRequiresComptime(child.toType()); + }, .array_type => |array_type| return sema.typeRequiresComptime(array_type.child.toType()), .vector_type => |vector_type| return sema.typeRequiresComptime(vector_type.child.toType()), .opt_type => |child| return sema.typeRequiresComptime(child.toType()), @@ -33733,7 +33732,6 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { .bool, .void, .anyerror, - .@"anyframe", .noreturn, .generic_poison, .atomic_order, |
