| author | |
| committer | |
| log | 0ecec5fcca3ae8f33bf307c2ca66b8d11baf3d1d |
| tree | c3b09089496106831a25e7597a0b59607e95c458 |
| parent | 352c71873b1c018fed8821d275b490be8c881792 |
5 files changed, 7 insertions(+), 55 deletions(-)
src/Sema.zig+2-4| ... | @@ -3319,8 +3319,6 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index | ... | @@ -3319,8 +3319,6 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index |
| 3319 | operand_ty.childType() | 3319 | operand_ty.childType() |
| 3320 | else | 3320 | else |
| 3321 | operand_ty; | 3321 | operand_ty; |
| 3322 | // TODO this should be validated in a more generic instruction that is | ||
| 3323 | // emitted for all ifs and whiles with an error union condition. | ||
| 3324 | if (err_union_ty.zigTypeTag() != .ErrorUnion) return; | 3322 | if (err_union_ty.zigTypeTag() != .ErrorUnion) return; |
| 3325 | const payload_ty = err_union_ty.errorUnionPayload().zigTypeTag(); | 3323 | const payload_ty = err_union_ty.errorUnionPayload().zigTypeTag(); |
| 3326 | if (payload_ty != .Void and payload_ty != .NoReturn) { | 3324 | if (payload_ty != .Void and payload_ty != .NoReturn) { |
| ... | @@ -21596,7 +21594,7 @@ fn zirVarExtended( | ... | @@ -21596,7 +21594,7 @@ fn zirVarExtended( |
| 21596 | .owner_decl = sema.owner_decl_index, | 21594 | .owner_decl = sema.owner_decl_index, |
| 21597 | .init = init_val, | 21595 | .init = init_val, |
| 21598 | .is_extern = small.is_extern, | 21596 | .is_extern = small.is_extern, |
| 21599 | .is_mutable = true, // TODO get rid of this unused field | 21597 | .is_mutable = true, |
| 21600 | .is_threadlocal = small.is_threadlocal, | 21598 | .is_threadlocal = small.is_threadlocal, |
| 21601 | .is_weak_linkage = false, | 21599 | .is_weak_linkage = false, |
| 21602 | .lib_name = null, | 21600 | .lib_name = null, |
| ... | @@ -22075,7 +22073,7 @@ fn zirBuiltinExtern( | ... | @@ -22075,7 +22073,7 @@ fn zirBuiltinExtern( |
| 22075 | .owner_decl = sema.owner_decl_index, | 22073 | .owner_decl = sema.owner_decl_index, |
| 22076 | .init = Value.initTag(.unreachable_value), | 22074 | .init = Value.initTag(.unreachable_value), |
| 22077 | .is_extern = true, | 22075 | .is_extern = true, |
| 22078 | .is_mutable = false, // TODO get rid of this unused field | 22076 | .is_mutable = false, |
| 22079 | .is_threadlocal = options.is_thread_local, | 22077 | .is_threadlocal = options.is_thread_local, |
| 22080 | .is_weak_linkage = options.linkage == .Weak, | 22078 | .is_weak_linkage = options.linkage == .Weak, |
| 22081 | .lib_name = null, | 22079 | .lib_name = null, |
src/Zir.zig+1-2| ... | @@ -100,8 +100,7 @@ pub fn nullTerminatedString(code: Zir, index: usize) [:0]const u8 { | ... | @@ -100,8 +100,7 @@ pub fn nullTerminatedString(code: Zir, index: usize) [:0]const u8 { |
| 100 | 100 | ||
| 101 | pub fn refSlice(code: Zir, start: usize, len: usize) []Inst.Ref { | 101 | pub fn refSlice(code: Zir, start: usize, len: usize) []Inst.Ref { |
| 102 | const raw_slice = code.extra[start..][0..len]; | 102 | const raw_slice = code.extra[start..][0..len]; |
| 103 | // TODO we should be able to directly `@ptrCast` the slice to the other slice type. | 103 | return @ptrCast([]Inst.Ref, raw_slice); |
| 104 | return @ptrCast([*]Inst.Ref, raw_slice.ptr)[0..len]; | ||
| 105 | } | 104 | } |
| 106 | 105 | ||
| 107 | pub fn hasCompileErrors(code: Zir) bool { | 106 | pub fn hasCompileErrors(code: Zir) bool { |
src/main.zig+1-2| ... | @@ -3412,8 +3412,7 @@ fn runOrTest( | ... | @@ -3412,8 +3412,7 @@ fn runOrTest( |
| 3412 | } else if (watch) { | 3412 | } else if (watch) { |
| 3413 | warn("process exited with code {d}", .{code}); | 3413 | warn("process exited with code {d}", .{code}); |
| 3414 | } else { | 3414 | } else { |
| 3415 | // TODO https://github.com/ziglang/zig/issues/6342 | 3415 | process.exit(code); |
| 3416 | process.exit(1); | ||
| 3417 | } | 3416 | } |
| 3418 | }, | 3417 | }, |
| 3419 | else => { | 3418 | else => { |
src/type.zig+2-44| ... | @@ -1236,7 +1236,7 @@ pub const Type = extern union { | ... | @@ -1236,7 +1236,7 @@ pub const Type = extern union { |
| 1236 | // we can't hash these based on tags because they wouldn't match the expanded version. | 1236 | // we can't hash these based on tags because they wouldn't match the expanded version. |
| 1237 | .type_info => unreachable, // needed to resolve the type before now | 1237 | .type_info => unreachable, // needed to resolve the type before now |
| 1238 | 1238 | ||
| 1239 | .bound_fn => unreachable, // TODO delete from the language | 1239 | .bound_fn => unreachable, |
| 1240 | .var_args_param => unreachable, // can be any type | 1240 | .var_args_param => unreachable, // can be any type |
| 1241 | } | 1241 | } |
| 1242 | } | 1242 | } |
| ... | @@ -3272,7 +3272,7 @@ pub const Type = extern union { | ... | @@ -3272,7 +3272,7 @@ pub const Type = extern union { |
| 3272 | .fn_ccc_void_no_args => unreachable, // represents machine code; not a pointer | 3272 | .fn_ccc_void_no_args => unreachable, // represents machine code; not a pointer |
| 3273 | .function => unreachable, // represents machine code; not a pointer | 3273 | .function => unreachable, // represents machine code; not a pointer |
| 3274 | .@"opaque" => unreachable, // no size available | 3274 | .@"opaque" => unreachable, // no size available |
| 3275 | .bound_fn => unreachable, // TODO remove from the language | 3275 | .bound_fn => unreachable, |
| 3276 | .noreturn => unreachable, | 3276 | .noreturn => unreachable, |
| 3277 | .inferred_alloc_const => unreachable, | 3277 | .inferred_alloc_const => unreachable, |
| 3278 | .inferred_alloc_mut => unreachable, | 3278 | .inferred_alloc_mut => unreachable, |
| ... | @@ -4088,47 +4088,6 @@ pub const Type = extern union { | ... | @@ -4088,47 +4088,6 @@ pub const Type = extern union { |
| 4088 | } | 4088 | } |
| 4089 | } | 4089 | } |
| 4090 | 4090 | ||
| 4091 | /// Returns if type can be used for a runtime variable | ||
| 4092 | pub fn isValidVarType(self: Type, is_extern: bool) bool { | ||
| 4093 | var ty = self; | ||
| 4094 | while (true) switch (ty.zigTypeTag()) { | ||
| 4095 | .Bool, | ||
| 4096 | .Int, | ||
| 4097 | .Float, | ||
| 4098 | .ErrorSet, | ||
| 4099 | .Enum, | ||
| 4100 | .Frame, | ||
| 4101 | .AnyFrame, | ||
| 4102 | => return true, | ||
| 4103 | |||
| 4104 | .Opaque => return is_extern, | ||
| 4105 | .ComptimeFloat, | ||
| 4106 | .ComptimeInt, | ||
| 4107 | .EnumLiteral, | ||
| 4108 | .NoReturn, | ||
| 4109 | .Type, | ||
| 4110 | .Void, | ||
| 4111 | .Undefined, | ||
| 4112 | .Null, | ||
| 4113 | => return false, | ||
| 4114 | |||
| 4115 | .Optional => { | ||
| 4116 | var buf: Payload.ElemType = undefined; | ||
| 4117 | return ty.optionalChild(&buf).isValidVarType(is_extern); | ||
| 4118 | }, | ||
| 4119 | .Pointer, .Array, .Vector => ty = ty.elemType(), | ||
| 4120 | .ErrorUnion => ty = ty.errorUnionPayload(), | ||
| 4121 | |||
| 4122 | .Fn => @panic("TODO fn isValidVarType"), | ||
| 4123 | .Struct => { | ||
| 4124 | // TODO this is not always correct; introduce lazy value mechanism | ||
| 4125 | // and here we need to force a resolve of "type requires comptime". | ||
| 4126 | return true; | ||
| 4127 | }, | ||
| 4128 | .Union => @panic("TODO union isValidVarType"), | ||
| 4129 | }; | ||
| 4130 | } | ||
| 4131 | |||
| 4132 | /// For *[N]T, returns [N]T. | 4091 | /// For *[N]T, returns [N]T. |
| 4133 | /// For *T, returns T. | 4092 | /// For *T, returns T. |
| 4134 | /// For [*]T, returns T. | 4093 | /// For [*]T, returns T. |
| ... | @@ -5434,7 +5393,6 @@ pub const Type = extern union { | ... | @@ -5434,7 +5393,6 @@ pub const Type = extern union { |
| 5434 | } | 5393 | } |
| 5435 | 5394 | ||
| 5436 | /// Asserts the type is an enum or a union. | 5395 | /// Asserts the type is an enum or a union. |
| 5437 | /// TODO support unions | ||
| 5438 | pub fn intTagType(ty: Type, buffer: *Payload.Bits) Type { | 5396 | pub fn intTagType(ty: Type, buffer: *Payload.Bits) Type { |
| 5439 | switch (ty.tag()) { | 5397 | switch (ty.tag()) { |
| 5440 | .enum_full, .enum_nonexhaustive => return ty.cast(Payload.EnumFull).?.data.tag_ty, | 5398 | .enum_full, .enum_nonexhaustive => return ty.cast(Payload.EnumFull).?.data.tag_ty, |
src/value.zig+1-3| ... | @@ -814,7 +814,6 @@ pub const Value = extern union { | ... | @@ -814,7 +814,6 @@ pub const Value = extern union { |
| 814 | .float_80 => return out_stream.print("{}", .{val.castTag(.float_80).?.data}), | 814 | .float_80 => return out_stream.print("{}", .{val.castTag(.float_80).?.data}), |
| 815 | .float_128 => return out_stream.print("{}", .{val.castTag(.float_128).?.data}), | 815 | .float_128 => return out_stream.print("{}", .{val.castTag(.float_128).?.data}), |
| 816 | .@"error" => return out_stream.print("error.{s}", .{val.castTag(.@"error").?.data.name}), | 816 | .@"error" => return out_stream.print("error.{s}", .{val.castTag(.@"error").?.data.name}), |
| 817 | // TODO to print this it should be error{ Set, Items }!T(val), but we need the type for that | ||
| 818 | .eu_payload => { | 817 | .eu_payload => { |
| 819 | try out_stream.writeAll("(eu_payload) "); | 818 | try out_stream.writeAll("(eu_payload) "); |
| 820 | val = val.castTag(.eu_payload).?.data; | 819 | val = val.castTag(.eu_payload).?.data; |
| ... | @@ -989,8 +988,7 @@ pub const Value = extern union { | ... | @@ -989,8 +988,7 @@ pub const Value = extern union { |
| 989 | switch (val.tag()) { | 988 | switch (val.tag()) { |
| 990 | .enum_field_index => { | 989 | .enum_field_index => { |
| 991 | const field_index = val.castTag(.enum_field_index).?.data; | 990 | const field_index = val.castTag(.enum_field_index).?.data; |
| 992 | // TODO should `@intToEnum` do this `@intCast` for you? | 991 | return @intToEnum(E, field_index); |
| 993 | return @intToEnum(E, @intCast(@typeInfo(E).Enum.tag_type, field_index)); | ||
| 994 | }, | 992 | }, |
| 995 | .the_only_possible_value => { | 993 | .the_only_possible_value => { |
| 996 | const fields = std.meta.fields(E); | 994 | const fields = std.meta.fields(E); |