diff options
| author | Vexu <git@vexu.eu> | 2020-11-11 13:52:42 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2020-11-11 16:04:46 +0200 |
| commit | 08270d72b404cab5c7cc2f5239c21f9fe3823ca3 (patch) | |
| tree | 23b049f05d18a89c95e86a8d1348e047cd305f34 /src | |
| parent | 61c51f0ac96f91254c6acc6c23b8d09f38b49480 (diff) | |
| download | zig-08270d72b404cab5c7cc2f5239c21f9fe3823ca3.tar.gz zig-08270d72b404cab5c7cc2f5239c21f9fe3823ca3.zip | |
ensure TypeInfo payload is not undefined
Diffstat (limited to 'src')
| -rw-r--r-- | src/stage1/ir.cpp | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index a984664cf8..a513bd6ee8 100644 --- a/src/stage1/ir.cpp +++ b/src/stage1/ir.cpp @@ -26022,6 +26022,32 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI return ira->codegen->builtin_types.entry_bool; case ZigTypeIdUnreachable: return ira->codegen->builtin_types.entry_unreachable; + case ZigTypeIdComptimeFloat: + return ira->codegen->builtin_types.entry_num_lit_float; + case ZigTypeIdComptimeInt: + return ira->codegen->builtin_types.entry_num_lit_int; + case ZigTypeIdUndefined: + return ira->codegen->builtin_types.entry_undef; + case ZigTypeIdNull: + return ira->codegen->builtin_types.entry_null; + case ZigTypeIdEnumLiteral: + return ira->codegen->builtin_types.entry_enum_literal; + default: + if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, source_instr->source_node, payload, UndefBad))) + return ira->codegen->invalid_inst_gen->value->type; + } + switch (tagTypeId) { + case ZigTypeIdInvalid: + case ZigTypeIdMetaType: + case ZigTypeIdVoid: + case ZigTypeIdBool: + case ZigTypeIdUnreachable: + case ZigTypeIdComptimeFloat: + case ZigTypeIdComptimeInt: + case ZigTypeIdUndefined: + case ZigTypeIdNull: + case ZigTypeIdEnumLiteral: + zig_unreachable(); case ZigTypeIdInt: { assert(payload->special == ConstValSpecialStatic); assert(payload->type == ir_type_info_get_type(ira, "Int", nullptr)); @@ -26131,14 +26157,6 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI return ira->codegen->invalid_inst_gen->value->type; return get_array_type(ira->codegen, elem_type, bigint_as_u64(bi), sentinel); } - case ZigTypeIdComptimeFloat: - return ira->codegen->builtin_types.entry_num_lit_float; - case ZigTypeIdComptimeInt: - return ira->codegen->builtin_types.entry_num_lit_int; - case ZigTypeIdUndefined: - return ira->codegen->builtin_types.entry_undef; - case ZigTypeIdNull: - return ira->codegen->builtin_types.entry_null; case ZigTypeIdOptional: { assert(payload->special == ConstValSpecialStatic); assert(payload->type == ir_type_info_get_type(ira, "Optional", nullptr)); @@ -26204,8 +26222,6 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI return get_any_frame_type(ira->codegen, child_type); } - case ZigTypeIdEnumLiteral: - return ira->codegen->builtin_types.entry_enum_literal; case ZigTypeIdFnFrame: { assert(payload->special == ConstValSpecialStatic); assert(payload->type == ir_type_info_get_type(ira, "Frame", nullptr)); |
