| ... | @@ -5466,21 +5466,30 @@ fn addStrLitNoAlias(sema: *Sema, bytes: []const u8) CompileError!Air.Inst.Ref { | ... | @@ -5466,21 +5466,30 @@ fn addStrLitNoAlias(sema: *Sema, bytes: []const u8) CompileError!Air.Inst.Ref { |
| 5466 | .ty = array_ty.toIntern(), | 5466 | .ty = array_ty.toIntern(), |
| 5467 | .storage = .{ .bytes = bytes }, | 5467 | .storage = .{ .bytes = bytes }, |
| 5468 | } }); | 5468 | } }); |
| 5469 | const ptr_ty = try sema.ptrType(.{ | 5469 | return anonDeclRef(sema, val); |
| 5470 | .child = array_ty.toIntern(), | 5470 | } |
| | 5471 | |
| | 5472 | fn anonDeclRef(sema: *Sema, val: InternPool.Index) CompileError!Air.Inst.Ref { |
| | 5473 | return Air.internedToRef(try refValue(sema, val)); |
| | 5474 | } |
| | 5475 | |
| | 5476 | fn refValue(sema: *Sema, val: InternPool.Index) CompileError!InternPool.Index { |
| | 5477 | const mod = sema.mod; |
| | 5478 | const ptr_ty = (try sema.ptrType(.{ |
| | 5479 | .child = mod.intern_pool.typeOf(val), |
| 5471 | .flags = .{ | 5480 | .flags = .{ |
| 5472 | .alignment = .none, | 5481 | .alignment = .none, |
| 5473 | .is_const = true, | 5482 | .is_const = true, |
| 5474 | .address_space = .generic, | 5483 | .address_space = .generic, |
| 5475 | }, | 5484 | }, |
| 5476 | }); | 5485 | })).toIntern(); |
| 5477 | return Air.internedToRef((try mod.intern(.{ .ptr = .{ | 5486 | return mod.intern(.{ .ptr = .{ |
| 5478 | .ty = ptr_ty.toIntern(), | 5487 | .ty = ptr_ty, |
| 5479 | .addr = .{ .anon_decl = .{ | 5488 | .addr = .{ .anon_decl = .{ |
| 5480 | .val = val, | 5489 | .val = val, |
| 5481 | .orig_ty = ptr_ty.toIntern(), | 5490 | .orig_ty = ptr_ty, |
| 5482 | } }, | 5491 | } }, |
| 5483 | } }))); | 5492 | } }); |
| 5484 | } | 5493 | } |
| 5485 | | 5494 | |
| 5486 | fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 5495 | fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -10740,7 +10749,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10740,7 +10749,7 @@ const SwitchProngAnalysis = struct { |
| 10740 | return block.addStructFieldVal(spa.operand, field_index, field_ty); | 10749 | return block.addStructFieldVal(spa.operand, field_index, field_ty); |
| 10741 | } | 10750 | } |
| 10742 | } else if (capture_byref) { | 10751 | } else if (capture_byref) { |
| 10743 | return sema.addConstantMaybeRef(block, operand_ty, item_val, true); | 10752 | return anonDeclRef(sema, item_val.toIntern()); |
| 10744 | } else { | 10753 | } else { |
| 10745 | return inline_case_capture; | 10754 | return inline_case_capture; |
| 10746 | } | 10755 | } |
| ... | @@ -13765,10 +13774,10 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13765,10 +13774,10 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13765 | const coerced_elem_val = try sema.resolveConstValue(block, .unneeded, coerced_elem_val_inst, undefined); | 13774 | const coerced_elem_val = try sema.resolveConstValue(block, .unneeded, coerced_elem_val_inst, undefined); |
| 13766 | element_vals[elem_i] = try coerced_elem_val.intern(resolved_elem_ty, mod); | 13775 | element_vals[elem_i] = try coerced_elem_val.intern(resolved_elem_ty, mod); |
| 13767 | } | 13776 | } |
| 13768 | return sema.addConstantMaybeRef(block, result_ty, (try mod.intern(.{ .aggregate = .{ | 13777 | return sema.addConstantMaybeRef(try mod.intern(.{ .aggregate = .{ |
| 13769 | .ty = result_ty.toIntern(), | 13778 | .ty = result_ty.toIntern(), |
| 13770 | .storage = .{ .elems = element_vals }, | 13779 | .storage = .{ .elems = element_vals }, |
| 13771 | } })).toValue(), ptr_addrspace != null); | 13780 | } }), ptr_addrspace != null); |
| 13772 | } else break :rs rhs_src; | 13781 | } else break :rs rhs_src; |
| 13773 | } else lhs_src; | 13782 | } else lhs_src; |
| 13774 | | 13783 | |
| ... | @@ -14034,7 +14043,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14034,7 +14043,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14034 | .storage = .{ .elems = element_vals }, | 14043 | .storage = .{ .elems = element_vals }, |
| 14035 | } }); | 14044 | } }); |
| 14036 | }; | 14045 | }; |
| 14037 | return sema.addConstantMaybeRef(block, result_ty, val.toValue(), ptr_addrspace != null); | 14046 | return sema.addConstantMaybeRef(val, ptr_addrspace != null); |
| 14038 | } | 14047 | } |
| 14039 | | 14048 | |
| 14040 | try sema.requireRuntimeBlock(block, src, lhs_src); | 14049 | try sema.requireRuntimeBlock(block, src, lhs_src); |
| ... | @@ -16724,54 +16733,49 @@ fn zirBuiltinSrc( | ... | @@ -16724,54 +16733,49 @@ fn zirBuiltinSrc( |
| 16724 | const src = LazySrcLoc.nodeOffset(extra.node); | 16733 | const src = LazySrcLoc.nodeOffset(extra.node); |
| 16725 | if (sema.func_index == .none) return sema.fail(block, src, "@src outside function", .{}); | 16734 | if (sema.func_index == .none) return sema.fail(block, src, "@src outside function", .{}); |
| 16726 | const fn_owner_decl = mod.funcOwnerDeclPtr(sema.func_index); | 16735 | const fn_owner_decl = mod.funcOwnerDeclPtr(sema.func_index); |
| | 16736 | const ip = &mod.intern_pool; |
| | 16737 | const gpa = sema.gpa; |
| 16727 | | 16738 | |
| 16728 | const func_name_val = blk: { | 16739 | const func_name_val = v: { |
| 16729 | var anon_decl = try block.startAnonDecl(); | 16740 | // This dupe prevents InternPool string pool memory from being reallocated |
| 16730 | defer anon_decl.deinit(); | 16741 | // while a reference exists. |
| 16731 | // TODO: write something like getCoercedInts to avoid needing to dupe | 16742 | const bytes = try sema.arena.dupe(u8, ip.stringToSlice(fn_owner_decl.name)); |
| 16732 | const name = try sema.arena.dupe(u8, mod.intern_pool.stringToSlice(fn_owner_decl.name)); | 16743 | const array_ty = try ip.get(gpa, .{ .array_type = .{ |
| 16733 | const new_decl_ty = try mod.arrayType(.{ | 16744 | .len = bytes.len, |
| 16734 | .len = name.len, | | |
| 16735 | .sentinel = .zero_u8, | 16745 | .sentinel = .zero_u8, |
| 16736 | .child = .u8_type, | 16746 | .child = .u8_type, |
| 16737 | }); | 16747 | } }); |
| 16738 | const new_decl = try anon_decl.finish( | 16748 | break :v try ip.get(gpa, .{ .ptr = .{ |
| 16739 | new_decl_ty, | | |
| 16740 | (try mod.intern(.{ .aggregate = .{ | | |
| 16741 | .ty = new_decl_ty.toIntern(), | | |
| 16742 | .storage = .{ .bytes = name }, | | |
| 16743 | } })).toValue(), | | |
| 16744 | .none, // default alignment | | |
| 16745 | ); | | |
| 16746 | break :blk try mod.intern(.{ .ptr = .{ | | |
| 16747 | .ty = .slice_const_u8_sentinel_0_type, | 16749 | .ty = .slice_const_u8_sentinel_0_type, |
| 16748 | .addr = .{ .decl = new_decl }, | 16750 | .len = (try mod.intValue(Type.usize, bytes.len)).toIntern(), |
| 16749 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 16751 | .addr = .{ .anon_decl = .{ |
| | 16752 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| | 16753 | .val = try ip.get(gpa, .{ .aggregate = .{ |
| | 16754 | .ty = array_ty, |
| | 16755 | .storage = .{ .bytes = bytes }, |
| | 16756 | } }), |
| | 16757 | } }, |
| 16750 | } }); | 16758 | } }); |
| 16751 | }; | 16759 | }; |
| 16752 | | 16760 | |
| 16753 | const file_name_val = blk: { | 16761 | const file_name_val = v: { |
| 16754 | var anon_decl = try block.startAnonDecl(); | | |
| 16755 | defer anon_decl.deinit(); | | |
| 16756 | // The compiler must not call realpath anywhere. | 16762 | // The compiler must not call realpath anywhere. |
| 16757 | const name = try fn_owner_decl.getFileScope(mod).fullPathZ(sema.arena); | 16763 | const bytes = try fn_owner_decl.getFileScope(mod).fullPathZ(sema.arena); |
| 16758 | const new_decl_ty = try mod.arrayType(.{ | 16764 | const array_ty = try ip.get(gpa, .{ .array_type = .{ |
| 16759 | .len = name.len, | 16765 | .len = bytes.len, |
| 16760 | .sentinel = .zero_u8, | 16766 | .sentinel = .zero_u8, |
| 16761 | .child = .u8_type, | 16767 | .child = .u8_type, |
| 16762 | }); | 16768 | } }); |
| 16763 | const new_decl = try anon_decl.finish( | 16769 | break :v try ip.get(gpa, .{ .ptr = .{ |
| 16764 | new_decl_ty, | | |
| 16765 | (try mod.intern(.{ .aggregate = .{ | | |
| 16766 | .ty = new_decl_ty.toIntern(), | | |
| 16767 | .storage = .{ .bytes = name }, | | |
| 16768 | } })).toValue(), | | |
| 16769 | .none, // default alignment | | |
| 16770 | ); | | |
| 16771 | break :blk try mod.intern(.{ .ptr = .{ | | |
| 16772 | .ty = .slice_const_u8_sentinel_0_type, | 16770 | .ty = .slice_const_u8_sentinel_0_type, |
| 16773 | .addr = .{ .decl = new_decl }, | 16771 | .len = (try mod.intValue(Type.usize, bytes.len)).toIntern(), |
| 16774 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 16772 | .addr = .{ .anon_decl = .{ |
| | 16773 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| | 16774 | .val = try ip.get(gpa, .{ .aggregate = .{ |
| | 16775 | .ty = array_ty, |
| | 16776 | .storage = .{ .bytes = bytes }, |
| | 16777 | } }), |
| | 16778 | } }, |
| 16775 | } }); | 16779 | } }); |
| 16776 | }; | 16780 | }; |
| 16777 | | 16781 | |
| ... | @@ -16818,10 +16822,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -16818,10 +16822,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16818 | .val = .void_value, | 16822 | .val = .void_value, |
| 16819 | } }))), | 16823 | } }))), |
| 16820 | .Fn => { | 16824 | .Fn => { |
| 16821 | // TODO: look into memoizing this result. | | |
| 16822 | var params_anon_decl = try block.startAnonDecl(); | | |
| 16823 | defer params_anon_decl.deinit(); | | |
| 16824 | | | |
| 16825 | const fn_info_decl_index = (try sema.namespaceLookup( | 16825 | const fn_info_decl_index = (try sema.namespaceLookup( |
| 16826 | block, | 16826 | block, |
| 16827 | src, | 16827 | src, |
| ... | @@ -16878,23 +16878,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -16878,23 +16878,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16878 | .len = param_vals.len, | 16878 | .len = param_vals.len, |
| 16879 | .child = param_info_ty.toIntern(), | 16879 | .child = param_info_ty.toIntern(), |
| 16880 | }); | 16880 | }); |
| 16881 | const new_decl = try params_anon_decl.finish( | 16881 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 16882 | new_decl_ty, | 16882 | .ty = new_decl_ty.toIntern(), |
| 16883 | (try mod.intern(.{ .aggregate = .{ | 16883 | .storage = .{ .elems = param_vals }, |
| 16884 | .ty = new_decl_ty.toIntern(), | 16884 | } }); |
| 16885 | .storage = .{ .elems = param_vals }, | 16885 | const ptr_ty = (try sema.ptrType(.{ |
| 16886 | } })).toValue(), | 16886 | .child = param_info_ty.toIntern(), |
| 16887 | .none, // default alignment | 16887 | .flags = .{ |
| 16888 | ); | 16888 | .size = .Slice, |
| | 16889 | .is_const = true, |
| | 16890 | }, |
| | 16891 | })).toIntern(); |
| 16889 | break :v try mod.intern(.{ .ptr = .{ | 16892 | break :v try mod.intern(.{ .ptr = .{ |
| 16890 | .ty = (try sema.ptrType(.{ | 16893 | .ty = ptr_ty, |
| 16891 | .child = param_info_ty.toIntern(), | 16894 | .addr = .{ .anon_decl = .{ |
| 16892 | .flags = .{ | 16895 | .orig_ty = ptr_ty, |
| 16893 | .size = .Slice, | 16896 | .val = new_decl_val, |
| 16894 | .is_const = true, | 16897 | } }, |
| 16895 | }, | | |
| 16896 | })).toIntern(), | | |
| 16897 | .addr = .{ .decl = new_decl }, | | |
| 16898 | .len = (try mod.intValue(Type.usize, param_vals.len)).toIntern(), | 16898 | .len = (try mod.intValue(Type.usize, param_vals.len)).toIntern(), |
| 16899 | } }); | 16899 | } }); |
| 16900 | }; | 16900 | }; |
| ... | @@ -17035,7 +17035,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17035,7 +17035,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17035 | // is_allowzero: bool, | 17035 | // is_allowzero: bool, |
| 17036 | Value.makeBool(info.flags.is_allowzero).toIntern(), | 17036 | Value.makeBool(info.flags.is_allowzero).toIntern(), |
| 17037 | // sentinel: ?*const anyopaque, | 17037 | // sentinel: ?*const anyopaque, |
| 17038 | (try sema.optRefValue(block, info.child.toType(), switch (info.sentinel) { | 17038 | (try sema.optRefValue(switch (info.sentinel) { |
| 17039 | .none => null, | 17039 | .none => null, |
| 17040 | else => info.sentinel.toValue(), | 17040 | else => info.sentinel.toValue(), |
| 17041 | })).toIntern(), | 17041 | })).toIntern(), |
| ... | @@ -17070,7 +17070,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17070,7 +17070,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17070 | // child: type, | 17070 | // child: type, |
| 17071 | info.elem_type.toIntern(), | 17071 | info.elem_type.toIntern(), |
| 17072 | // sentinel: ?*const anyopaque, | 17072 | // sentinel: ?*const anyopaque, |
| 17073 | (try sema.optRefValue(block, info.elem_type, info.sentinel)).toIntern(), | 17073 | (try sema.optRefValue(info.sentinel)).toIntern(), |
| 17074 | }; | 17074 | }; |
| 17075 | return Air.internedToRef((try mod.intern(.{ .un = .{ | 17075 | return Air.internedToRef((try mod.intern(.{ .un = .{ |
| 17076 | .ty = type_info_ty.toIntern(), | 17076 | .ty = type_info_ty.toIntern(), |
| ... | @@ -17139,9 +17139,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17139,9 +17139,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17139 | } }))); | 17139 | } }))); |
| 17140 | }, | 17140 | }, |
| 17141 | .ErrorSet => { | 17141 | .ErrorSet => { |
| 17142 | var fields_anon_decl = try block.startAnonDecl(); | | |
| 17143 | defer fields_anon_decl.deinit(); | | |
| 17144 | | | |
| 17145 | // Get the Error type | 17142 | // Get the Error type |
| 17146 | const error_field_ty = t: { | 17143 | const error_field_ty = t: { |
| 17147 | const set_field_ty_decl_index = (try sema.namespaceLookup( | 17144 | const set_field_ty_decl_index = (try sema.namespaceLookup( |
| ... | @@ -17170,23 +17167,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17170,23 +17167,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17170 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17167 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17171 | const name = try sema.arena.dupe(u8, ip.stringToSlice(names.get(ip)[i])); | 17168 | const name = try sema.arena.dupe(u8, ip.stringToSlice(names.get(ip)[i])); |
| 17172 | const name_val = v: { | 17169 | const name_val = v: { |
| 17173 | var anon_decl = try block.startAnonDecl(); | | |
| 17174 | defer anon_decl.deinit(); | | |
| 17175 | const new_decl_ty = try mod.arrayType(.{ | 17170 | const new_decl_ty = try mod.arrayType(.{ |
| 17176 | .len = name.len, | 17171 | .len = name.len, |
| 17177 | .child = .u8_type, | 17172 | .child = .u8_type, |
| 17178 | }); | 17173 | }); |
| 17179 | const new_decl = try anon_decl.finish( | 17174 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17180 | new_decl_ty, | 17175 | .ty = new_decl_ty.toIntern(), |
| 17181 | (try mod.intern(.{ .aggregate = .{ | 17176 | .storage = .{ .bytes = name }, |
| 17182 | .ty = new_decl_ty.toIntern(), | 17177 | } }); |
| 17183 | .storage = .{ .bytes = name }, | | |
| 17184 | } })).toValue(), | | |
| 17185 | .none, // default alignment | | |
| 17186 | ); | | |
| 17187 | break :v try mod.intern(.{ .ptr = .{ | 17178 | break :v try mod.intern(.{ .ptr = .{ |
| 17188 | .ty = .slice_const_u8_type, | 17179 | .ty = .slice_const_u8_type, |
| 17189 | .addr = .{ .decl = new_decl }, | 17180 | .addr = .{ .anon_decl = .{ |
| | 17181 | .val = new_decl_val, |
| | 17182 | .orig_ty = .slice_const_u8_type, |
| | 17183 | } }, |
| 17190 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 17184 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17191 | } }); | 17185 | } }); |
| 17192 | }; | 17186 | }; |
| ... | @@ -17219,17 +17213,16 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17219,17 +17213,16 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17219 | .len = vals.len, | 17213 | .len = vals.len, |
| 17220 | .child = error_field_ty.toIntern(), | 17214 | .child = error_field_ty.toIntern(), |
| 17221 | }); | 17215 | }); |
| 17222 | const new_decl = try fields_anon_decl.finish( | 17216 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17223 | array_errors_ty, | 17217 | .ty = array_errors_ty.toIntern(), |
| 17224 | (try mod.intern(.{ .aggregate = .{ | 17218 | .storage = .{ .elems = vals }, |
| 17225 | .ty = array_errors_ty.toIntern(), | 17219 | } }); |
| 17226 | .storage = .{ .elems = vals }, | | |
| 17227 | } })).toValue(), | | |
| 17228 | .none, // default alignment | | |
| 17229 | ); | | |
| 17230 | break :v try mod.intern(.{ .ptr = .{ | 17220 | break :v try mod.intern(.{ .ptr = .{ |
| 17231 | .ty = slice_errors_ty.toIntern(), | 17221 | .ty = slice_errors_ty.toIntern(), |
| 17232 | .addr = .{ .decl = new_decl }, | 17222 | .addr = .{ .anon_decl = .{ |
| | 17223 | .orig_ty = slice_errors_ty.toIntern(), |
| | 17224 | .val = new_decl_val, |
| | 17225 | } }, |
| 17233 | .len = (try mod.intValue(Type.usize, vals.len)).toIntern(), | 17226 | .len = (try mod.intValue(Type.usize, vals.len)).toIntern(), |
| 17234 | } }); | 17227 | } }); |
| 17235 | } else .none; | 17228 | } else .none; |
| ... | @@ -17275,12 +17268,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17275,12 +17268,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17275 | } }))); | 17268 | } }))); |
| 17276 | }, | 17269 | }, |
| 17277 | .Enum => { | 17270 | .Enum => { |
| 17278 | // TODO: look into memoizing this result. | | |
| 17279 | const is_exhaustive = Value.makeBool(ip.indexToKey(ty.toIntern()).enum_type.tag_mode != .nonexhaustive); | 17271 | const is_exhaustive = Value.makeBool(ip.indexToKey(ty.toIntern()).enum_type.tag_mode != .nonexhaustive); |
| 17280 | | 17272 | |
| 17281 | var fields_anon_decl = try block.startAnonDecl(); | | |
| 17282 | defer fields_anon_decl.deinit(); | | |
| 17283 | | | |
| 17284 | const enum_field_ty = t: { | 17273 | const enum_field_ty = t: { |
| 17285 | const enum_field_ty_decl_index = (try sema.namespaceLookup( | 17274 | const enum_field_ty_decl_index = (try sema.namespaceLookup( |
| 17286 | block, | 17275 | block, |
| ... | @@ -17308,23 +17297,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17308,23 +17297,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17308 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17297 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17309 | const name = try sema.arena.dupe(u8, ip.stringToSlice(enum_type.names.get(ip)[i])); | 17298 | const name = try sema.arena.dupe(u8, ip.stringToSlice(enum_type.names.get(ip)[i])); |
| 17310 | const name_val = v: { | 17299 | const name_val = v: { |
| 17311 | var anon_decl = try block.startAnonDecl(); | | |
| 17312 | defer anon_decl.deinit(); | | |
| 17313 | const new_decl_ty = try mod.arrayType(.{ | 17300 | const new_decl_ty = try mod.arrayType(.{ |
| 17314 | .len = name.len, | 17301 | .len = name.len, |
| 17315 | .child = .u8_type, | 17302 | .child = .u8_type, |
| 17316 | }); | 17303 | }); |
| 17317 | const new_decl = try anon_decl.finish( | 17304 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17318 | new_decl_ty, | 17305 | .ty = new_decl_ty.toIntern(), |
| 17319 | (try mod.intern(.{ .aggregate = .{ | 17306 | .storage = .{ .bytes = name }, |
| 17320 | .ty = new_decl_ty.toIntern(), | 17307 | } }); |
| 17321 | .storage = .{ .bytes = name }, | | |
| 17322 | } })).toValue(), | | |
| 17323 | .none, // default alignment | | |
| 17324 | ); | | |
| 17325 | break :v try mod.intern(.{ .ptr = .{ | 17308 | break :v try mod.intern(.{ .ptr = .{ |
| 17326 | .ty = .slice_const_u8_type, | 17309 | .ty = .slice_const_u8_type, |
| 17327 | .addr = .{ .decl = new_decl }, | 17310 | .addr = .{ .anon_decl = .{ |
| | 17311 | .val = new_decl_val, |
| | 17312 | .orig_ty = .slice_const_u8_type, |
| | 17313 | } }, |
| 17328 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 17314 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17329 | } }); | 17315 | } }); |
| 17330 | }; | 17316 | }; |
| ... | @@ -17346,23 +17332,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17346,23 +17332,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17346 | .len = enum_field_vals.len, | 17332 | .len = enum_field_vals.len, |
| 17347 | .child = enum_field_ty.toIntern(), | 17333 | .child = enum_field_ty.toIntern(), |
| 17348 | }); | 17334 | }); |
| 17349 | const new_decl = try fields_anon_decl.finish( | 17335 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17350 | fields_array_ty, | 17336 | .ty = fields_array_ty.toIntern(), |
| 17351 | (try mod.intern(.{ .aggregate = .{ | 17337 | .storage = .{ .elems = enum_field_vals }, |
| 17352 | .ty = fields_array_ty.toIntern(), | 17338 | } }); |
| 17353 | .storage = .{ .elems = enum_field_vals }, | 17339 | const ptr_ty = (try sema.ptrType(.{ |
| 17354 | } })).toValue(), | 17340 | .child = enum_field_ty.toIntern(), |
| 17355 | .none, // default alignment | 17341 | .flags = .{ |
| 17356 | ); | 17342 | .size = .Slice, |
| | 17343 | .is_const = true, |
| | 17344 | }, |
| | 17345 | })).toIntern(); |
| 17357 | break :v try mod.intern(.{ .ptr = .{ | 17346 | break :v try mod.intern(.{ .ptr = .{ |
| 17358 | .ty = (try sema.ptrType(.{ | 17347 | .ty = ptr_ty, |
| 17359 | .child = enum_field_ty.toIntern(), | 17348 | .addr = .{ .anon_decl = .{ |
| 17360 | .flags = .{ | 17349 | .val = new_decl_val, |
| 17361 | .size = .Slice, | 17350 | .orig_ty = ptr_ty, |
| 17362 | .is_const = true, | 17351 | } }, |
| 17363 | }, | | |
| 17364 | })).toIntern(), | | |
| 17365 | .addr = .{ .decl = new_decl }, | | |
| 17366 | .len = (try mod.intValue(Type.usize, enum_field_vals.len)).toIntern(), | 17352 | .len = (try mod.intValue(Type.usize, enum_field_vals.len)).toIntern(), |
| 17367 | } }); | 17353 | } }); |
| 17368 | }; | 17354 | }; |
| ... | @@ -17402,11 +17388,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17402,11 +17388,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17402 | } }))); | 17388 | } }))); |
| 17403 | }, | 17389 | }, |
| 17404 | .Union => { | 17390 | .Union => { |
| 17405 | // TODO: look into memoizing this result. | | |
| 17406 | | | |
| 17407 | var fields_anon_decl = try block.startAnonDecl(); | | |
| 17408 | defer fields_anon_decl.deinit(); | | |
| 17409 | | | |
| 17410 | const type_union_ty = t: { | 17391 | const type_union_ty = t: { |
| 17411 | const type_union_ty_decl_index = (try sema.namespaceLookup( | 17392 | const type_union_ty_decl_index = (try sema.namespaceLookup( |
| 17412 | block, | 17393 | block, |
| ... | @@ -17444,23 +17425,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17444,23 +17425,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17444 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17425 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17445 | const name = try sema.arena.dupe(u8, ip.stringToSlice(union_obj.field_names.get(ip)[i])); | 17426 | const name = try sema.arena.dupe(u8, ip.stringToSlice(union_obj.field_names.get(ip)[i])); |
| 17446 | const name_val = v: { | 17427 | const name_val = v: { |
| 17447 | var anon_decl = try block.startAnonDecl(); | | |
| 17448 | defer anon_decl.deinit(); | | |
| 17449 | const new_decl_ty = try mod.arrayType(.{ | 17428 | const new_decl_ty = try mod.arrayType(.{ |
| 17450 | .len = name.len, | 17429 | .len = name.len, |
| 17451 | .child = .u8_type, | 17430 | .child = .u8_type, |
| 17452 | }); | 17431 | }); |
| 17453 | const new_decl = try anon_decl.finish( | 17432 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17454 | new_decl_ty, | 17433 | .ty = new_decl_ty.toIntern(), |
| 17455 | (try mod.intern(.{ .aggregate = .{ | 17434 | .storage = .{ .bytes = name }, |
| 17456 | .ty = new_decl_ty.toIntern(), | 17435 | } }); |
| 17457 | .storage = .{ .bytes = name }, | | |
| 17458 | } })).toValue(), | | |
| 17459 | .none, // default alignment | | |
| 17460 | ); | | |
| 17461 | break :v try mod.intern(.{ .ptr = .{ | 17436 | break :v try mod.intern(.{ .ptr = .{ |
| 17462 | .ty = .slice_const_u8_type, | 17437 | .ty = .slice_const_u8_type, |
| 17463 | .addr = .{ .decl = new_decl }, | 17438 | .addr = .{ .anon_decl = .{ |
| | 17439 | .val = new_decl_val, |
| | 17440 | .orig_ty = .slice_const_u8_type, |
| | 17441 | } }, |
| 17464 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 17442 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17465 | } }); | 17443 | } }); |
| 17466 | }; | 17444 | }; |
| ... | @@ -17490,23 +17468,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17490,23 +17468,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17490 | .len = union_field_vals.len, | 17468 | .len = union_field_vals.len, |
| 17491 | .child = union_field_ty.toIntern(), | 17469 | .child = union_field_ty.toIntern(), |
| 17492 | }); | 17470 | }); |
| 17493 | const new_decl = try fields_anon_decl.finish( | 17471 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17494 | array_fields_ty, | 17472 | .ty = array_fields_ty.toIntern(), |
| 17495 | (try mod.intern(.{ .aggregate = .{ | 17473 | .storage = .{ .elems = union_field_vals }, |
| 17496 | .ty = array_fields_ty.toIntern(), | 17474 | } }); |
| 17497 | .storage = .{ .elems = union_field_vals }, | 17475 | const ptr_ty = (try sema.ptrType(.{ |
| 17498 | } })).toValue(), | 17476 | .child = union_field_ty.toIntern(), |
| 17499 | .none, // default alignment | 17477 | .flags = .{ |
| 17500 | ); | 17478 | .size = .Slice, |
| | 17479 | .is_const = true, |
| | 17480 | }, |
| | 17481 | })).toIntern(); |
| 17501 | break :v try mod.intern(.{ .ptr = .{ | 17482 | break :v try mod.intern(.{ .ptr = .{ |
| 17502 | .ty = (try sema.ptrType(.{ | 17483 | .ty = ptr_ty, |
| 17503 | .child = union_field_ty.toIntern(), | 17484 | .addr = .{ .anon_decl = .{ |
| 17504 | .flags = .{ | 17485 | .orig_ty = ptr_ty, |
| 17505 | .size = .Slice, | 17486 | .val = new_decl_val, |
| 17506 | .is_const = true, | 17487 | } }, |
| 17507 | }, | | |
| 17508 | })).toIntern(), | | |
| 17509 | .addr = .{ .decl = new_decl }, | | |
| 17510 | .len = (try mod.intValue(Type.usize, union_field_vals.len)).toIntern(), | 17488 | .len = (try mod.intValue(Type.usize, union_field_vals.len)).toIntern(), |
| 17511 | } }); | 17489 | } }); |
| 17512 | }; | 17490 | }; |
| ... | @@ -17552,11 +17530,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17552,11 +17530,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17552 | } }))); | 17530 | } }))); |
| 17553 | }, | 17531 | }, |
| 17554 | .Struct => { | 17532 | .Struct => { |
| 17555 | // TODO: look into memoizing this result. | | |
| 17556 | | | |
| 17557 | var fields_anon_decl = try block.startAnonDecl(); | | |
| 17558 | defer fields_anon_decl.deinit(); | | |
| 17559 | | | |
| 17560 | const type_struct_ty = t: { | 17533 | const type_struct_ty = t: { |
| 17561 | const type_struct_ty_decl_index = (try sema.namespaceLookup( | 17534 | const type_struct_ty_decl_index = (try sema.namespaceLookup( |
| 17562 | block, | 17535 | block, |
| ... | @@ -17596,8 +17569,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17596,8 +17569,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17596 | const field_ty = anon_struct_type.types.get(ip)[i]; | 17569 | const field_ty = anon_struct_type.types.get(ip)[i]; |
| 17597 | const field_val = anon_struct_type.values.get(ip)[i]; | 17570 | const field_val = anon_struct_type.values.get(ip)[i]; |
| 17598 | const name_val = v: { | 17571 | const name_val = v: { |
| 17599 | var anon_decl = try block.startAnonDecl(); | | |
| 17600 | defer anon_decl.deinit(); | | |
| 17601 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17572 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17602 | const bytes = if (tuple.names.len != 0) | 17573 | const bytes = if (tuple.names.len != 0) |
| 17603 | // https://github.com/ziglang/zig/issues/15709 | 17574 | // https://github.com/ziglang/zig/issues/15709 |
| ... | @@ -17608,17 +17579,16 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17608,17 +17579,16 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17608 | .len = bytes.len, | 17579 | .len = bytes.len, |
| 17609 | .child = .u8_type, | 17580 | .child = .u8_type, |
| 17610 | }); | 17581 | }); |
| 17611 | const new_decl = try anon_decl.finish( | 17582 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17612 | new_decl_ty, | 17583 | .ty = new_decl_ty.toIntern(), |
| 17613 | (try mod.intern(.{ .aggregate = .{ | 17584 | .storage = .{ .bytes = bytes }, |
| 17614 | .ty = new_decl_ty.toIntern(), | 17585 | } }); |
| 17615 | .storage = .{ .bytes = bytes }, | | |
| 17616 | } })).toValue(), | | |
| 17617 | .none, // default alignment | | |
| 17618 | ); | | |
| 17619 | break :v try mod.intern(.{ .ptr = .{ | 17586 | break :v try mod.intern(.{ .ptr = .{ |
| 17620 | .ty = .slice_const_u8_type, | 17587 | .ty = .slice_const_u8_type, |
| 17621 | .addr = .{ .decl = new_decl }, | 17588 | .addr = .{ .anon_decl = .{ |
| | 17589 | .val = new_decl_val, |
| | 17590 | .orig_ty = .slice_const_u8_type, |
| | 17591 | } }, |
| 17622 | .len = (try mod.intValue(Type.usize, bytes.len)).toIntern(), | 17592 | .len = (try mod.intValue(Type.usize, bytes.len)).toIntern(), |
| 17623 | } }); | 17593 | } }); |
| 17624 | }; | 17594 | }; |
| ... | @@ -17627,7 +17597,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17627,7 +17597,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17627 | | 17597 | |
| 17628 | const is_comptime = field_val != .none; | 17598 | const is_comptime = field_val != .none; |
| 17629 | const opt_default_val = if (is_comptime) field_val.toValue() else null; | 17599 | const opt_default_val = if (is_comptime) field_val.toValue() else null; |
| 17630 | const default_val_ptr = try sema.optRefValue(block, field_ty.toType(), opt_default_val); | 17600 | const default_val_ptr = try sema.optRefValue(opt_default_val); |
| 17631 | const struct_field_fields = .{ | 17601 | const struct_field_fields = .{ |
| 17632 | // name: []const u8, | 17602 | // name: []const u8, |
| 17633 | name_val, | 17603 | name_val, |
| ... | @@ -17662,29 +17632,26 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17662,29 +17632,26 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17662 | const field_init = struct_type.fieldInit(ip, i); | 17632 | const field_init = struct_type.fieldInit(ip, i); |
| 17663 | const field_is_comptime = struct_type.fieldIsComptime(ip, i); | 17633 | const field_is_comptime = struct_type.fieldIsComptime(ip, i); |
| 17664 | const name_val = v: { | 17634 | const name_val = v: { |
| 17665 | var anon_decl = try block.startAnonDecl(); | | |
| 17666 | defer anon_decl.deinit(); | | |
| 17667 | const new_decl_ty = try mod.arrayType(.{ | 17635 | const new_decl_ty = try mod.arrayType(.{ |
| 17668 | .len = name.len, | 17636 | .len = name.len, |
| 17669 | .child = .u8_type, | 17637 | .child = .u8_type, |
| 17670 | }); | 17638 | }); |
| 17671 | const new_decl = try anon_decl.finish( | 17639 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17672 | new_decl_ty, | 17640 | .ty = new_decl_ty.toIntern(), |
| 17673 | (try mod.intern(.{ .aggregate = .{ | 17641 | .storage = .{ .bytes = name }, |
| 17674 | .ty = new_decl_ty.toIntern(), | 17642 | } }); |
| 17675 | .storage = .{ .bytes = name }, | | |
| 17676 | } })).toValue(), | | |
| 17677 | .none, // default alignment | | |
| 17678 | ); | | |
| 17679 | break :v try mod.intern(.{ .ptr = .{ | 17643 | break :v try mod.intern(.{ .ptr = .{ |
| 17680 | .ty = .slice_const_u8_type, | 17644 | .ty = .slice_const_u8_type, |
| 17681 | .addr = .{ .decl = new_decl }, | 17645 | .addr = .{ .anon_decl = .{ |
| | 17646 | .val = new_decl_val, |
| | 17647 | .orig_ty = .slice_const_u8_type, |
| | 17648 | } }, |
| 17682 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 17649 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17683 | } }); | 17650 | } }); |
| 17684 | }; | 17651 | }; |
| 17685 | | 17652 | |
| 17686 | const opt_default_val = if (field_init == .none) null else field_init.toValue(); | 17653 | const opt_default_val = if (field_init == .none) null else field_init.toValue(); |
| 17687 | const default_val_ptr = try sema.optRefValue(block, field_ty, opt_default_val); | 17654 | const default_val_ptr = try sema.optRefValue(opt_default_val); |
| 17688 | const alignment = switch (struct_type.layout) { | 17655 | const alignment = switch (struct_type.layout) { |
| 17689 | .Packed => .none, | 17656 | .Packed => .none, |
| 17690 | else => try sema.structFieldAlignment( | 17657 | else => try sema.structFieldAlignment( |
| ... | @@ -17718,23 +17685,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17718,23 +17685,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17718 | .len = struct_field_vals.len, | 17685 | .len = struct_field_vals.len, |
| 17719 | .child = struct_field_ty.toIntern(), | 17686 | .child = struct_field_ty.toIntern(), |
| 17720 | }); | 17687 | }); |
| 17721 | const new_decl = try fields_anon_decl.finish( | 17688 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17722 | array_fields_ty, | 17689 | .ty = array_fields_ty.toIntern(), |
| 17723 | (try mod.intern(.{ .aggregate = .{ | 17690 | .storage = .{ .elems = struct_field_vals }, |
| 17724 | .ty = array_fields_ty.toIntern(), | 17691 | } }); |
| 17725 | .storage = .{ .elems = struct_field_vals }, | 17692 | const ptr_ty = (try sema.ptrType(.{ |
| 17726 | } })).toValue(), | 17693 | .child = struct_field_ty.toIntern(), |
| 17727 | .none, // default alignment | 17694 | .flags = .{ |
| 17728 | ); | 17695 | .size = .Slice, |
| | 17696 | .is_const = true, |
| | 17697 | }, |
| | 17698 | })).toIntern(); |
| 17729 | break :v try mod.intern(.{ .ptr = .{ | 17699 | break :v try mod.intern(.{ .ptr = .{ |
| 17730 | .ty = (try sema.ptrType(.{ | 17700 | .ty = ptr_ty, |
| 17731 | .child = struct_field_ty.toIntern(), | 17701 | .addr = .{ .anon_decl = .{ |
| 17732 | .flags = .{ | 17702 | .orig_ty = ptr_ty, |
| 17733 | .size = .Slice, | 17703 | .val = new_decl_val, |
| 17734 | .is_const = true, | 17704 | } }, |
| 17735 | }, | | |
| 17736 | })).toIntern(), | | |
| 17737 | .addr = .{ .decl = new_decl }, | | |
| 17738 | .len = (try mod.intValue(Type.usize, struct_field_vals.len)).toIntern(), | 17705 | .len = (try mod.intValue(Type.usize, struct_field_vals.len)).toIntern(), |
| 17739 | } }); | 17706 | } }); |
| 17740 | }; | 17707 | }; |
| ... | @@ -17786,8 +17753,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17786,8 +17753,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17786 | } }))); | 17753 | } }))); |
| 17787 | }, | 17754 | }, |
| 17788 | .Opaque => { | 17755 | .Opaque => { |
| 17789 | // TODO: look into memoizing this result. | | |
| 17790 | | | |
| 17791 | const type_opaque_ty = t: { | 17756 | const type_opaque_ty = t: { |
| 17792 | const type_opaque_ty_decl_index = (try sema.namespaceLookup( | 17757 | const type_opaque_ty_decl_index = (try sema.namespaceLookup( |
| 17793 | block, | 17758 | block, |
| ... | @@ -17832,9 +17797,6 @@ fn typeInfoDecls( | ... | @@ -17832,9 +17797,6 @@ fn typeInfoDecls( |
| 17832 | const mod = sema.mod; | 17797 | const mod = sema.mod; |
| 17833 | const gpa = sema.gpa; | 17798 | const gpa = sema.gpa; |
| 17834 | | 17799 | |
| 17835 | var decls_anon_decl = try block.startAnonDecl(); | | |
| 17836 | defer decls_anon_decl.deinit(); | | |
| 17837 | | | |
| 17838 | const declaration_ty = t: { | 17800 | const declaration_ty = t: { |
| 17839 | const declaration_ty_decl_index = (try sema.namespaceLookup( | 17801 | const declaration_ty_decl_index = (try sema.namespaceLookup( |
| 17840 | block, | 17802 | block, |
| ... | @@ -17864,23 +17826,23 @@ fn typeInfoDecls( | ... | @@ -17864,23 +17826,23 @@ fn typeInfoDecls( |
| 17864 | .len = decl_vals.items.len, | 17826 | .len = decl_vals.items.len, |
| 17865 | .child = declaration_ty.toIntern(), | 17827 | .child = declaration_ty.toIntern(), |
| 17866 | }); | 17828 | }); |
| 17867 | const new_decl = try decls_anon_decl.finish( | 17829 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17868 | array_decl_ty, | 17830 | .ty = array_decl_ty.toIntern(), |
| 17869 | (try mod.intern(.{ .aggregate = .{ | 17831 | .storage = .{ .elems = decl_vals.items }, |
| 17870 | .ty = array_decl_ty.toIntern(), | 17832 | } }); |
| 17871 | .storage = .{ .elems = decl_vals.items }, | 17833 | const ptr_ty = (try sema.ptrType(.{ |
| 17872 | } })).toValue(), | 17834 | .child = declaration_ty.toIntern(), |
| 17873 | .none, // default alignment | 17835 | .flags = .{ |
| 17874 | ); | 17836 | .size = .Slice, |
| | 17837 | .is_const = true, |
| | 17838 | }, |
| | 17839 | })).toIntern(); |
| 17875 | return try mod.intern(.{ .ptr = .{ | 17840 | return try mod.intern(.{ .ptr = .{ |
| 17876 | .ty = (try sema.ptrType(.{ | 17841 | .ty = ptr_ty, |
| 17877 | .child = declaration_ty.toIntern(), | 17842 | .addr = .{ .anon_decl = .{ |
| 17878 | .flags = .{ | 17843 | .orig_ty = ptr_ty, |
| 17879 | .size = .Slice, | 17844 | .val = new_decl_val, |
| 17880 | .is_const = true, | 17845 | } }, |
| 17881 | }, | | |
| 17882 | })).toIntern(), | | |
| 17883 | .addr = .{ .decl = new_decl }, | | |
| 17884 | .len = (try mod.intValue(Type.usize, decl_vals.items.len)).toIntern(), | 17846 | .len = (try mod.intValue(Type.usize, decl_vals.items.len)).toIntern(), |
| 17885 | } }); | 17847 | } }); |
| 17886 | } | 17848 | } |
| ... | @@ -17909,25 +17871,22 @@ fn typeInfoNamespaceDecls( | ... | @@ -17909,25 +17871,22 @@ fn typeInfoNamespaceDecls( |
| 17909 | } | 17871 | } |
| 17910 | if (decl.kind != .named or !decl.is_pub) continue; | 17872 | if (decl.kind != .named or !decl.is_pub) continue; |
| 17911 | const name_val = v: { | 17873 | const name_val = v: { |
| 17912 | var anon_decl = try block.startAnonDecl(); | | |
| 17913 | defer anon_decl.deinit(); | | |
| 17914 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17874 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17915 | const name = try sema.arena.dupe(u8, ip.stringToSlice(decl.name)); | 17875 | const name = try sema.arena.dupe(u8, ip.stringToSlice(decl.name)); |
| 17916 | const new_decl_ty = try mod.arrayType(.{ | 17876 | const new_decl_ty = try mod.arrayType(.{ |
| 17917 | .len = name.len, | 17877 | .len = name.len, |
| 17918 | .child = .u8_type, | 17878 | .child = .u8_type, |
| 17919 | }); | 17879 | }); |
| 17920 | const new_decl = try anon_decl.finish( | 17880 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| 17921 | new_decl_ty, | 17881 | .ty = new_decl_ty.toIntern(), |
| 17922 | (try mod.intern(.{ .aggregate = .{ | 17882 | .storage = .{ .bytes = name }, |
| 17923 | .ty = new_decl_ty.toIntern(), | 17883 | } }); |
| 17924 | .storage = .{ .bytes = name }, | | |
| 17925 | } })).toValue(), | | |
| 17926 | .none, // default alignment | | |
| 17927 | ); | | |
| 17928 | break :v try mod.intern(.{ .ptr = .{ | 17884 | break :v try mod.intern(.{ .ptr = .{ |
| 17929 | .ty = .slice_const_u8_type, | 17885 | .ty = .slice_const_u8_type, |
| 17930 | .addr = .{ .decl = new_decl }, | 17886 | .addr = .{ .anon_decl = .{ |
| | 17887 | .orig_ty = .slice_const_u8_type, |
| | 17888 | .val = new_decl_val, |
| | 17889 | } }, |
| 17931 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 17890 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17932 | } }); | 17891 | } }); |
| 17933 | }; | 17892 | }; |
| ... | @@ -19072,10 +19031,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is | ... | @@ -19072,10 +19031,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is |
| 19072 | | 19031 | |
| 19073 | if (is_byref) { | 19032 | if (is_byref) { |
| 19074 | const init_val = (try sema.resolveValue(init_ref)).?; | 19033 | const init_val = (try sema.resolveValue(init_ref)).?; |
| 19075 | var anon_decl = try block.startAnonDecl(); | 19034 | return anonDeclRef(sema, init_val.toIntern()); |
| 19076 | defer anon_decl.deinit(); | | |
| 19077 | const decl = try anon_decl.finish(init_ty, init_val, .none); | | |
| 19078 | return sema.analyzeDeclRef(decl); | | |
| 19079 | } else { | 19035 | } else { |
| 19080 | return init_ref; | 19036 | return init_ref; |
| 19081 | } | 19037 | } |
| ... | @@ -19298,7 +19254,7 @@ fn zirStructInit( | ... | @@ -19298,7 +19254,7 @@ fn zirStructInit( |
| 19298 | } })).toValue(); | 19254 | } })).toValue(); |
| 19299 | const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val.toIntern()), src); | 19255 | const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val.toIntern()), src); |
| 19300 | const final_val = (try sema.resolveValue(final_val_inst)).?; | 19256 | const final_val = (try sema.resolveValue(final_val_inst)).?; |
| 19301 | return sema.addConstantMaybeRef(block, resolved_ty, final_val, is_ref); | 19257 | return sema.addConstantMaybeRef(final_val.toIntern(), is_ref); |
| 19302 | } | 19258 | } |
| 19303 | | 19259 | |
| 19304 | if (try sema.typeRequiresComptime(resolved_ty)) { | 19260 | if (try sema.typeRequiresComptime(resolved_ty)) { |
| ... | @@ -19458,7 +19414,7 @@ fn finishStructInit( | ... | @@ -19458,7 +19414,7 @@ fn finishStructInit( |
| 19458 | } }); | 19414 | } }); |
| 19459 | const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val), init_src); | 19415 | const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val), init_src); |
| 19460 | const final_val = (try sema.resolveValue(final_val_inst)).?; | 19416 | const final_val = (try sema.resolveValue(final_val_inst)).?; |
| 19461 | return sema.addConstantMaybeRef(block, result_ty, final_val, is_ref); | 19417 | return sema.addConstantMaybeRef(final_val.toIntern(), is_ref); |
| 19462 | }; | 19418 | }; |
| 19463 | | 19419 | |
| 19464 | if (try sema.typeRequiresComptime(struct_ty)) { | 19420 | if (try sema.typeRequiresComptime(struct_ty)) { |
| ... | @@ -19611,7 +19567,7 @@ fn structInitAnon( | ... | @@ -19611,7 +19567,7 @@ fn structInitAnon( |
| 19611 | .ty = tuple_ty, | 19567 | .ty = tuple_ty, |
| 19612 | .storage = .{ .elems = values }, | 19568 | .storage = .{ .elems = values }, |
| 19613 | } }); | 19569 | } }); |
| 19614 | return sema.addConstantMaybeRef(block, tuple_ty.toType(), tuple_val.toValue(), is_ref); | 19570 | return sema.addConstantMaybeRef(tuple_val, is_ref); |
| 19615 | }; | 19571 | }; |
| 19616 | | 19572 | |
| 19617 | sema.requireRuntimeBlock(block, .unneeded, null) catch |err| switch (err) { | 19573 | sema.requireRuntimeBlock(block, .unneeded, null) catch |err| switch (err) { |
| ... | @@ -19777,7 +19733,8 @@ fn zirArrayInit( | ... | @@ -19777,7 +19733,8 @@ fn zirArrayInit( |
| 19777 | .storage = .{ .elems = elem_vals }, | 19733 | .storage = .{ .elems = elem_vals }, |
| 19778 | } }); | 19734 | } }); |
| 19779 | const result_ref = try sema.coerce(block, result_ty, Air.internedToRef(arr_val), src); | 19735 | const result_ref = try sema.coerce(block, result_ty, Air.internedToRef(arr_val), src); |
| 19780 | return sema.addConstantMaybeRef(block, result_ty, (try sema.resolveValue(result_ref)).?, is_ref); | 19736 | const result_val = (try sema.resolveValue(result_ref)).?; |
| | 19737 | return sema.addConstantMaybeRef(result_val.toIntern(), is_ref); |
| 19781 | }; | 19738 | }; |
| 19782 | | 19739 | |
| 19783 | sema.requireRuntimeBlock(block, .unneeded, null) catch |err| switch (err) { | 19740 | sema.requireRuntimeBlock(block, .unneeded, null) catch |err| switch (err) { |
| ... | @@ -19896,7 +19853,7 @@ fn arrayInitAnon( | ... | @@ -19896,7 +19853,7 @@ fn arrayInitAnon( |
| 19896 | .ty = tuple_ty, | 19853 | .ty = tuple_ty, |
| 19897 | .storage = .{ .elems = values }, | 19854 | .storage = .{ .elems = values }, |
| 19898 | } }); | 19855 | } }); |
| 19899 | return sema.addConstantMaybeRef(block, tuple_ty.toType(), tuple_val.toValue(), is_ref); | 19856 | return sema.addConstantMaybeRef(tuple_val, is_ref); |
| 19900 | }; | 19857 | }; |
| 19901 | | 19858 | |
| 19902 | try sema.requireRuntimeBlock(block, src, runtime_src); | 19859 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| ... | @@ -19931,23 +19888,8 @@ fn arrayInitAnon( | ... | @@ -19931,23 +19888,8 @@ fn arrayInitAnon( |
| 19931 | return block.addAggregateInit(tuple_ty.toType(), element_refs); | 19888 | return block.addAggregateInit(tuple_ty.toType(), element_refs); |
| 19932 | } | 19889 | } |
| 19933 | | 19890 | |
| 19934 | fn addConstantMaybeRef( | 19891 | fn addConstantMaybeRef(sema: *Sema, val: InternPool.Index, is_ref: bool) !Air.Inst.Ref { |
| 19935 | sema: *Sema, | 19892 | return if (is_ref) anonDeclRef(sema, val) else Air.internedToRef(val); |
| 19936 | block: *Block, | | |
| 19937 | ty: Type, | | |
| 19938 | val: Value, | | |
| 19939 | is_ref: bool, | | |
| 19940 | ) !Air.Inst.Ref { | | |
| 19941 | if (!is_ref) return Air.internedToRef(val.toIntern()); | | |
| 19942 | | | |
| 19943 | var anon_decl = try block.startAnonDecl(); | | |
| 19944 | defer anon_decl.deinit(); | | |
| 19945 | const decl = try anon_decl.finish( | | |
| 19946 | ty, | | |
| 19947 | val, | | |
| 19948 | .none, // default alignment | | |
| 19949 | ); | | |
| 19950 | return sema.analyzeDeclRef(decl); | | |
| 19951 | } | 19893 | } |
| 19952 | | 19894 | |
| 19953 | fn zirFieldTypeRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 19895 | fn zirFieldTypeRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -21429,28 +21371,9 @@ fn zirTypeName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -21429,28 +21371,9 @@ fn zirTypeName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 21429 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 21371 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 21430 | const ty = try sema.resolveType(block, ty_src, inst_data.operand); | 21372 | const ty = try sema.resolveType(block, ty_src, inst_data.operand); |
| 21431 | | 21373 | |
| 21432 | var anon_decl = try block.startAnonDecl(); | | |
| 21433 | defer anon_decl.deinit(); | | |
| 21434 | | | |
| 21435 | var bytes = std.ArrayList(u8).init(sema.arena); | 21374 | var bytes = std.ArrayList(u8).init(sema.arena); |
| 21436 | defer bytes.deinit(); | | |
| 21437 | try ty.print(bytes.writer(), mod); | 21375 | try ty.print(bytes.writer(), mod); |
| 21438 | | 21376 | return addStrLitNoAlias(sema, bytes.items); |
| 21439 | const decl_ty = try mod.arrayType(.{ | | |
| 21440 | .len = bytes.items.len, | | |
| 21441 | .sentinel = .zero_u8, | | |
| 21442 | .child = .u8_type, | | |
| 21443 | }); | | |
| 21444 | const new_decl = try anon_decl.finish( | | |
| 21445 | decl_ty, | | |
| 21446 | (try mod.intern(.{ .aggregate = .{ | | |
| 21447 | .ty = decl_ty.toIntern(), | | |
| 21448 | .storage = .{ .bytes = bytes.items }, | | |
| 21449 | } })).toValue(), | | |
| 21450 | .none, // default alignment | | |
| 21451 | ); | | |
| 21452 | | | |
| 21453 | return sema.analyzeDeclRef(new_decl); | | |
| 21454 | } | 21377 | } |
| 21455 | | 21378 | |
| 21456 | fn zirFrameType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 21379 | fn zirFrameType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -26333,13 +26256,8 @@ fn fieldPtr( | ... | @@ -26333,13 +26256,8 @@ fn fieldPtr( |
| 26333 | switch (inner_ty.zigTypeTag(mod)) { | 26256 | switch (inner_ty.zigTypeTag(mod)) { |
| 26334 | .Array => { | 26257 | .Array => { |
| 26335 | if (ip.stringEqlSlice(field_name, "len")) { | 26258 | if (ip.stringEqlSlice(field_name, "len")) { |
| 26336 | var anon_decl = try block.startAnonDecl(); | 26259 | const int_val = try mod.intValue(Type.usize, inner_ty.arrayLen(mod)); |
| 26337 | defer anon_decl.deinit(); | 26260 | return anonDeclRef(sema, int_val.toIntern()); |
| 26338 | return sema.analyzeDeclRef(try anon_decl.finish( | | |
| 26339 | Type.usize, | | |
| 26340 | try mod.intValue(Type.usize, inner_ty.arrayLen(mod)), | | |
| 26341 | .none, // default alignment | | |
| 26342 | )); | | |
| 26343 | } else { | 26261 | } else { |
| 26344 | return sema.fail( | 26262 | return sema.fail( |
| 26345 | block, | 26263 | block, |
| ... | @@ -26448,20 +26366,14 @@ fn fieldPtr( | ... | @@ -26448,20 +26366,14 @@ fn fieldPtr( |
| 26448 | else => unreachable, | 26366 | else => unreachable, |
| 26449 | } | 26367 | } |
| 26450 | | 26368 | |
| 26451 | var anon_decl = try block.startAnonDecl(); | | |
| 26452 | defer anon_decl.deinit(); | | |
| 26453 | const error_set_type = if (!child_type.isAnyError(mod)) | 26369 | const error_set_type = if (!child_type.isAnyError(mod)) |
| 26454 | child_type | 26370 | child_type |
| 26455 | else | 26371 | else |
| 26456 | try mod.singleErrorSetType(field_name); | 26372 | try mod.singleErrorSetType(field_name); |
| 26457 | return sema.analyzeDeclRef(try anon_decl.finish( | 26373 | return anonDeclRef(sema, try mod.intern(.{ .err = .{ |
| 26458 | error_set_type, | 26374 | .ty = error_set_type.toIntern(), |
| 26459 | (try mod.intern(.{ .err = .{ | 26375 | .name = field_name, |
| 26460 | .ty = error_set_type.toIntern(), | 26376 | } })); |
| 26461 | .name = field_name, | | |
| 26462 | } })).toValue(), | | |
| 26463 | .none, // default alignment | | |
| 26464 | )); | | |
| 26465 | }, | 26377 | }, |
| 26466 | .Union => { | 26378 | .Union => { |
| 26467 | if (child_type.getNamespaceIndex(mod).unwrap()) |namespace| { | 26379 | if (child_type.getNamespaceIndex(mod).unwrap()) |namespace| { |
| ... | @@ -26473,13 +26385,8 @@ fn fieldPtr( | ... | @@ -26473,13 +26385,8 @@ fn fieldPtr( |
| 26473 | if (child_type.unionTagType(mod)) |enum_ty| { | 26385 | if (child_type.unionTagType(mod)) |enum_ty| { |
| 26474 | if (enum_ty.enumFieldIndex(field_name, mod)) |field_index| { | 26386 | if (enum_ty.enumFieldIndex(field_name, mod)) |field_index| { |
| 26475 | const field_index_u32: u32 = @intCast(field_index); | 26387 | const field_index_u32: u32 = @intCast(field_index); |
| 26476 | var anon_decl = try block.startAnonDecl(); | 26388 | const idx_val = try mod.enumValueFieldIndex(enum_ty, field_index_u32); |
| 26477 | defer anon_decl.deinit(); | 26389 | return anonDeclRef(sema, idx_val.toIntern()); |
| 26478 | return sema.analyzeDeclRef(try anon_decl.finish( | | |
| 26479 | enum_ty, | | |
| 26480 | try mod.enumValueFieldIndex(enum_ty, field_index_u32), | | |
| 26481 | .none, // default alignment | | |
| 26482 | )); | | |
| 26483 | } | 26390 | } |
| 26484 | } | 26391 | } |
| 26485 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); | 26392 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| ... | @@ -26494,13 +26401,8 @@ fn fieldPtr( | ... | @@ -26494,13 +26401,8 @@ fn fieldPtr( |
| 26494 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); | 26401 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| 26495 | }; | 26402 | }; |
| 26496 | const field_index_u32: u32 = @intCast(field_index); | 26403 | const field_index_u32: u32 = @intCast(field_index); |
| 26497 | var anon_decl = try block.startAnonDecl(); | 26404 | const idx_val = try mod.enumValueFieldIndex(child_type, field_index_u32); |
| 26498 | defer anon_decl.deinit(); | 26405 | return anonDeclRef(sema, idx_val.toIntern()); |
| 26499 | return sema.analyzeDeclRef(try anon_decl.finish( | | |
| 26500 | child_type, | | |
| 26501 | try mod.enumValueFieldIndex(child_type, field_index_u32), | | |
| 26502 | .none, // default alignment | | |
| 26503 | )); | | |
| 26504 | }, | 26406 | }, |
| 26505 | .Struct, .Opaque => { | 26407 | .Struct, .Opaque => { |
| 26506 | if (child_type.getNamespaceIndex(mod).unwrap()) |namespace| { | 26408 | if (child_type.getNamespaceIndex(mod).unwrap()) |namespace| { |
| ... | @@ -31669,31 +31571,13 @@ fn ensureFuncBodyAnalyzed(sema: *Sema, func: InternPool.Index) CompileError!void | ... | @@ -31669,31 +31571,13 @@ fn ensureFuncBodyAnalyzed(sema: *Sema, func: InternPool.Index) CompileError!void |
| 31669 | }; | 31571 | }; |
| 31670 | } | 31572 | } |
| 31671 | | 31573 | |
| 31672 | fn refValue(sema: *Sema, block: *Block, ty: Type, val: Value) !Value { | 31574 | fn optRefValue(sema: *Sema, opt_val: ?Value) !Value { |
| 31673 | const mod = sema.mod; | | |
| 31674 | var anon_decl = try block.startAnonDecl(); | | |
| 31675 | defer anon_decl.deinit(); | | |
| 31676 | const decl = try anon_decl.finish( | | |
| 31677 | ty, | | |
| 31678 | val, | | |
| 31679 | .none, // default alignment | | |
| 31680 | ); | | |
| 31681 | try sema.maybeQueueFuncBodyAnalysis(decl); | | |
| 31682 | try mod.declareDeclDependency(sema.owner_decl_index, decl); | | |
| 31683 | const result = try mod.intern(.{ .ptr = .{ | | |
| 31684 | .ty = (try mod.singleConstPtrType(ty)).toIntern(), | | |
| 31685 | .addr = .{ .decl = decl }, | | |
| 31686 | } }); | | |
| 31687 | return result.toValue(); | | |
| 31688 | } | | |
| 31689 | | | |
| 31690 | fn optRefValue(sema: *Sema, block: *Block, ty: Type, opt_val: ?Value) !Value { | | |
| 31691 | const mod = sema.mod; | 31575 | const mod = sema.mod; |
| 31692 | const ptr_anyopaque_ty = try mod.singleConstPtrType(Type.anyopaque); | 31576 | const ptr_anyopaque_ty = try mod.singleConstPtrType(Type.anyopaque); |
| 31693 | return (try mod.intern(.{ .opt = .{ | 31577 | return (try mod.intern(.{ .opt = .{ |
| 31694 | .ty = (try mod.optionalType(ptr_anyopaque_ty.toIntern())).toIntern(), | 31578 | .ty = (try mod.optionalType(ptr_anyopaque_ty.toIntern())).toIntern(), |
| 31695 | .val = if (opt_val) |val| (try mod.getCoerced( | 31579 | .val = if (opt_val) |val| (try mod.getCoerced( |
| 31696 | try sema.refValue(block, ty, val), | 31580 | (try sema.refValue(val.toIntern())).toValue(), |
| 31697 | ptr_anyopaque_ty, | 31581 | ptr_anyopaque_ty, |
| 31698 | )).toIntern() else .none, | 31582 | )).toIntern() else .none, |
| 31699 | } })).toValue(); | 31583 | } })).toValue(); |
| ... | @@ -31755,15 +31639,8 @@ fn analyzeRef( | ... | @@ -31755,15 +31639,8 @@ fn analyzeRef( |
| 31755 | switch (mod.intern_pool.indexToKey(val.toIntern())) { | 31639 | switch (mod.intern_pool.indexToKey(val.toIntern())) { |
| 31756 | .extern_func => |extern_func| return sema.analyzeDeclRef(extern_func.decl), | 31640 | .extern_func => |extern_func| return sema.analyzeDeclRef(extern_func.decl), |
| 31757 | .func => |func| return sema.analyzeDeclRef(func.owner_decl), | 31641 | .func => |func| return sema.analyzeDeclRef(func.owner_decl), |
| 31758 | else => {}, | 31642 | else => return anonDeclRef(sema, val.toIntern()), |
| 31759 | } | 31643 | } |
| 31760 | var anon_decl = try block.startAnonDecl(); | | |
| 31761 | defer anon_decl.deinit(); | | |
| 31762 | return sema.analyzeDeclRef(try anon_decl.finish( | | |
| 31763 | operand_ty, | | |
| 31764 | val, | | |
| 31765 | .none, // default alignment | | |
| 31766 | )); | | |
| 31767 | } | 31644 | } |
| 31768 | | 31645 | |
| 31769 | try sema.requireRuntimeBlock(block, src, null); | 31646 | try sema.requireRuntimeBlock(block, src, null); |
| ... | @@ -36848,7 +36725,7 @@ fn analyzeComptimeAlloc( | ... | @@ -36848,7 +36725,7 @@ fn analyzeComptimeAlloc( |
| 36848 | }, | 36725 | }, |
| 36849 | }); | 36726 | }); |
| 36850 | | 36727 | |
| 36851 | var anon_decl = try block.startAnonDecl(); | 36728 | var anon_decl = try block.startAnonDecl(); // TODO: comptime value mutation without Decl |
| 36852 | defer anon_decl.deinit(); | 36729 | defer anon_decl.deinit(); |
| 36853 | | 36730 | |
| 36854 | const decl_index = try anon_decl.finish( | 36731 | const decl_index = try anon_decl.finish( |