| author | |
| committer | |
| log | 19961c50e4db10fc4ada428928a7f5d1a2966da6 |
| tree | d5cf83c4a206d78617655df1f152eaeaeea61a7c |
| parent | 6f88ecc9b6ca4249912b7a9cffbad6d9b8819bc2 |
closes #11184 files changed, 14 insertions(+), 4 deletions(-)
src/analyze.cpp+1| ... | ... | @@ -3728,6 +3728,7 @@ TypeUnionField *find_union_field_by_tag(TypeTableEntry *type_entry, const BigInt |
| 3728 | 3728 | } |
| 3729 | 3729 | |
| 3730 | 3730 | TypeEnumField *find_enum_field_by_tag(TypeTableEntry *enum_type, const BigInt *tag) { |
| 3731 | assert(enum_type->data.enumeration.zero_bits_known); | |
| 3731 | 3732 | for (uint32_t i = 0; i < enum_type->data.enumeration.src_field_count; i += 1) { |
| 3732 | 3733 | TypeEnumField *field = &enum_type->data.enumeration.fields[i]; |
| 3733 | 3734 | if (bigint_cmp(&field->value, tag) == CmpEQ) { |
src/ir.cpp+3| ... | ... | @@ -16053,6 +16053,9 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIn |
| 16053 | 16053 | assert(target->value.type->id == TypeTableEntryIdEnum); |
| 16054 | 16054 | |
| 16055 | 16055 | if (instr_is_comptime(target)) { |
| 16056 | type_ensure_zero_bits_known(ira->codegen, target->value.type); | |
| 16057 | if (type_is_invalid(target->value.type)) | |
| 16058 | return ira->codegen->builtin_types.entry_invalid; | |
| 16056 | 16059 | TypeEnumField *field = find_enum_field_by_tag(target->value.type, &target->value.data.x_bigint); |
| 16057 | 16060 | ConstExprValue *array_val = create_const_str_lit(ira->codegen, field->name); |
| 16058 | 16061 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
test/cases/eval.zig+5| ... | ... | @@ -637,3 +637,8 @@ test "call method with comptime pass-by-non-copying-value self parameter" { |
| 637 | 637 | var b = s.b(); |
| 638 | 638 | assert(b == 2); |
| 639 | 639 | } |
| 640 | ||
| 641 | test "@tagName of @typeId" { | |
| 642 | const str = @tagName(@typeId(u8)); | |
| 643 | assert(std.mem.eql(u8, str, "Int")); | |
| 644 | } |
test/cases/widening.zig+5-4| ... | ... | @@ -19,8 +19,9 @@ test "implicit unsigned integer to signed integer" { |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | test "float widening" { |
| 22 | var a: f32 = 12.34; | |
| 23 | var b: f64 = a; | |
| 24 | var c: f128 = b; | |
| 25 | assert(c == a); | |
| 22 | var a: f16 = 12.34; | |
| 23 | var b: f32 = a; | |
| 24 | var c: f64 = b; | |
| 25 | var d: f128 = c; | |
| 26 | assert(d == a); | |
| 26 | 27 | } |