| ... | @@ -7920,7 +7920,6 @@ fn zirVarExtended( | ... | @@ -7920,7 +7920,6 @@ fn zirVarExtended( |
| 7920 | const mut_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at mut token | 7920 | const mut_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at mut token |
| 7921 | const init_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at init expr | 7921 | const init_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at init expr |
| 7922 | const small = @bitCast(Zir.Inst.ExtendedVar.Small, extended.small); | 7922 | const small = @bitCast(Zir.Inst.ExtendedVar.Small, extended.small); |
| 7923 | const var_ty = try sema.resolveType(block, ty_src, extra.data.var_type); | | |
| 7924 | | 7923 | |
| 7925 | var extra_index: usize = extra.end; | 7924 | var extra_index: usize = extra.end; |
| 7926 | | 7925 | |
| ... | @@ -7940,11 +7939,25 @@ fn zirVarExtended( | ... | @@ -7940,11 +7939,25 @@ fn zirVarExtended( |
| 7940 | // break :blk align_tv.val; | 7939 | // break :blk align_tv.val; |
| 7941 | //} else Value.initTag(.null_value); | 7940 | //} else Value.initTag(.null_value); |
| 7942 | | 7941 | |
| 7943 | const init_val: Value = if (small.has_init) blk: { | 7942 | const uncasted_init: Air.Inst.Ref = if (small.has_init) blk: { |
| 7944 | const init_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); | 7943 | const init_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 7945 | extra_index += 1; | 7944 | extra_index += 1; |
| 7946 | const init_air_inst = sema.resolveInst(init_ref); | 7945 | break :blk sema.resolveInst(init_ref); |
| 7947 | break :blk (try sema.resolveMaybeUndefVal(block, init_src, init_air_inst)) orelse | 7946 | } else .none; |
| | 7947 | |
| | 7948 | const have_ty = extra.data.var_type != .none; |
| | 7949 | const var_ty = if (have_ty) |
| | 7950 | try sema.resolveType(block, ty_src, extra.data.var_type) |
| | 7951 | else |
| | 7952 | sema.typeOf(uncasted_init); |
| | 7953 | |
| | 7954 | const init_val = if (uncasted_init != .none) blk: { |
| | 7955 | const init = if (have_ty) |
| | 7956 | try sema.coerce(block, var_ty, uncasted_init, init_src) |
| | 7957 | else |
| | 7958 | uncasted_init; |
| | 7959 | |
| | 7960 | break :blk (try sema.resolveMaybeUndefVal(block, init_src, init)) orelse |
| 7948 | return sema.failWithNeededComptime(block, init_src); | 7961 | return sema.failWithNeededComptime(block, init_src); |
| 7949 | } else Value.initTag(.unreachable_value); | 7962 | } else Value.initTag(.unreachable_value); |
| 7950 | | 7963 | |