| ... | ... | @@ -131,7 +131,6 @@ const CompileError = Module.CompileError; |
| 131 | 131 | const SemaError = Module.SemaError; |
| 132 | 132 | const Decl = Module.Decl; |
| 133 | 133 | const CaptureScope = Module.CaptureScope; |
| 134 | | const WipCaptureScope = Module.WipCaptureScope; |
| 135 | 134 | const LazySrcLoc = Module.LazySrcLoc; |
| 136 | 135 | const RangeSet = @import("RangeSet.zig"); |
| 137 | 136 | const target_util = @import("target.zig"); |
| ... | ... | @@ -308,7 +307,7 @@ pub const Block = struct { |
| 308 | 307 | /// used to add a `func_instance` into the `InternPool`. |
| 309 | 308 | params: std.MultiArrayList(Param) = .{}, |
| 310 | 309 | |
| 311 | | wip_capture_scope: *CaptureScope, |
| 310 | wip_capture_scope: CaptureScope.Index, |
| 312 | 311 | |
| 313 | 312 | label: ?*Label = null, |
| 314 | 313 | inlining: ?*Inlining, |
| ... | ... | @@ -951,21 +950,12 @@ fn analyzeBodyInner( |
| 951 | 950 | // different values for the same Zir.Inst.Index, so in those cases, we will |
| 952 | 951 | // have to create nested capture scopes; see the `.repeat` case below. |
| 953 | 952 | const parent_capture_scope = block.wip_capture_scope; |
| 954 | | parent_capture_scope.incRef(); |
| 955 | | var wip_captures: WipCaptureScope = .{ |
| 956 | | .scope = parent_capture_scope, |
| 957 | | .gpa = sema.gpa, |
| 958 | | .finalized = true, // don't finalize the parent scope |
| 959 | | }; |
| 960 | | defer wip_captures.deinit(); |
| 961 | 953 | |
| 962 | 954 | const mod = sema.mod; |
| 963 | 955 | const map = &sema.inst_map; |
| 964 | 956 | const tags = sema.code.instructions.items(.tag); |
| 965 | 957 | const datas = sema.code.instructions.items(.data); |
| 966 | 958 | |
| 967 | | var orig_captures: usize = parent_capture_scope.captures.count(); |
| 968 | | |
| 969 | 959 | var crash_info = crash_report.prepAnalyzeBody(sema, block, body); |
| 970 | 960 | crash_info.push(); |
| 971 | 961 | defer crash_info.pop(); |
| ... | ... | @@ -1500,16 +1490,11 @@ fn analyzeBodyInner( |
| 1500 | 1490 | // Send comptime control flow back to the beginning of this block. |
| 1501 | 1491 | const src = LazySrcLoc.nodeOffset(datas[inst].node); |
| 1502 | 1492 | try sema.emitBackwardBranch(block, src); |
| 1503 | | if (wip_captures.scope.captures.count() != orig_captures) { |
| 1504 | | // We need to construct new capture scopes for the next loop iteration so it |
| 1505 | | // can capture values without clobbering the earlier iteration's captures. |
| 1506 | | // At first, we reused the parent capture scope as an optimization, but for |
| 1507 | | // successive scopes we have to create new ones as children of the parent |
| 1508 | | // scope. |
| 1509 | | try wip_captures.reset(parent_capture_scope); |
| 1510 | | block.wip_capture_scope = wip_captures.scope; |
| 1511 | | orig_captures = 0; |
| 1512 | | } |
| 1493 | |
| 1494 | // We need to construct new capture scopes for the next loop iteration so it |
| 1495 | // can capture values without clobbering the earlier iteration's captures. |
| 1496 | block.wip_capture_scope = try mod.createCaptureScope(parent_capture_scope); |
| 1497 | |
| 1513 | 1498 | i = 0; |
| 1514 | 1499 | continue; |
| 1515 | 1500 | } else { |
| ... | ... | @@ -1520,16 +1505,11 @@ fn analyzeBodyInner( |
| 1520 | 1505 | // Send comptime control flow back to the beginning of this block. |
| 1521 | 1506 | const src = LazySrcLoc.nodeOffset(datas[inst].node); |
| 1522 | 1507 | try sema.emitBackwardBranch(block, src); |
| 1523 | | if (wip_captures.scope.captures.count() != orig_captures) { |
| 1524 | | // We need to construct new capture scopes for the next loop iteration so it |
| 1525 | | // can capture values without clobbering the earlier iteration's captures. |
| 1526 | | // At first, we reused the parent capture scope as an optimization, but for |
| 1527 | | // successive scopes we have to create new ones as children of the parent |
| 1528 | | // scope. |
| 1529 | | try wip_captures.reset(parent_capture_scope); |
| 1530 | | block.wip_capture_scope = wip_captures.scope; |
| 1531 | | orig_captures = 0; |
| 1532 | | } |
| 1508 | |
| 1509 | // We need to construct new capture scopes for the next loop iteration so it |
| 1510 | // can capture values without clobbering the earlier iteration's captures. |
| 1511 | block.wip_capture_scope = try mod.createCaptureScope(parent_capture_scope); |
| 1512 | |
| 1533 | 1513 | i = 0; |
| 1534 | 1514 | continue; |
| 1535 | 1515 | }, |
| ... | ... | @@ -1803,12 +1783,9 @@ fn analyzeBodyInner( |
| 1803 | 1783 | } |
| 1804 | 1784 | if (noreturn_inst) |some| try block.instructions.append(sema.gpa, some); |
| 1805 | 1785 | |
| 1806 | | if (!wip_captures.finalized) { |
| 1807 | | // We've updated the capture scope due to a `repeat` instruction where |
| 1808 | | // the body had a capture; finalize our child scope and reset |
| 1809 | | try wip_captures.finalize(); |
| 1810 | | block.wip_capture_scope = parent_capture_scope; |
| 1811 | | } |
| 1786 | // We may have overwritten the capture scope due to a `repeat` instruction where |
| 1787 | // the body had a capture; restore it now. |
| 1788 | block.wip_capture_scope = parent_capture_scope; |
| 1812 | 1789 | |
| 1813 | 1790 | return result; |
| 1814 | 1791 | } |
| ... | ... | @@ -3157,15 +3134,12 @@ fn zirEnumDecl( |
| 3157 | 3134 | sema.func_index = .none; |
| 3158 | 3135 | defer sema.func_index = prev_func_index; |
| 3159 | 3136 | |
| 3160 | | var wip_captures = try WipCaptureScope.init(gpa, new_decl.src_scope); |
| 3161 | | defer wip_captures.deinit(); |
| 3162 | | |
| 3163 | 3137 | var enum_block: Block = .{ |
| 3164 | 3138 | .parent = null, |
| 3165 | 3139 | .sema = sema, |
| 3166 | 3140 | .src_decl = new_decl_index, |
| 3167 | 3141 | .namespace = new_namespace_index, |
| 3168 | | .wip_capture_scope = wip_captures.scope, |
| 3142 | .wip_capture_scope = try mod.createCaptureScope(new_decl.src_scope), |
| 3169 | 3143 | .instructions = .{}, |
| 3170 | 3144 | .inlining = null, |
| 3171 | 3145 | .is_comptime = true, |
| ... | ... | @@ -3176,8 +3150,6 @@ fn zirEnumDecl( |
| 3176 | 3150 | try sema.analyzeBody(&enum_block, body); |
| 3177 | 3151 | } |
| 3178 | 3152 | |
| 3179 | | try wip_captures.finalize(); |
| 3180 | | |
| 3181 | 3153 | if (tag_type_ref != .none) { |
| 3182 | 3154 | const ty = try sema.resolveType(block, tag_ty_src, tag_type_ref); |
| 3183 | 3155 | if (ty.zigTypeTag(mod) != .Int and ty.zigTypeTag(mod) != .ComptimeInt) { |
| ... | ... | @@ -7298,15 +7270,12 @@ fn analyzeCall( |
| 7298 | 7270 | |
| 7299 | 7271 | try mod.declareDeclDependencyType(ics.callee().owner_decl_index, module_fn.owner_decl, .function_body); |
| 7300 | 7272 | |
| 7301 | | var wip_captures = try WipCaptureScope.init(gpa, fn_owner_decl.src_scope); |
| 7302 | | defer wip_captures.deinit(); |
| 7303 | | |
| 7304 | 7273 | var child_block: Block = .{ |
| 7305 | 7274 | .parent = null, |
| 7306 | 7275 | .sema = sema, |
| 7307 | 7276 | .src_decl = module_fn.owner_decl, |
| 7308 | 7277 | .namespace = fn_owner_decl.src_namespace, |
| 7309 | | .wip_capture_scope = wip_captures.scope, |
| 7278 | .wip_capture_scope = try mod.createCaptureScope(fn_owner_decl.src_scope), |
| 7310 | 7279 | .instructions = .{}, |
| 7311 | 7280 | .label = null, |
| 7312 | 7281 | .inlining = &inlining, |
| ... | ... | @@ -7514,8 +7483,6 @@ fn analyzeCall( |
| 7514 | 7483 | break :res2 result; |
| 7515 | 7484 | }; |
| 7516 | 7485 | |
| 7517 | | try wip_captures.finalize(); |
| 7518 | | |
| 7519 | 7486 | break :res res2; |
| 7520 | 7487 | } else res: { |
| 7521 | 7488 | assert(!func_ty_info.is_generic); |
| ... | ... | @@ -7840,15 +7807,12 @@ fn instantiateGenericCall( |
| 7840 | 7807 | }; |
| 7841 | 7808 | defer child_sema.deinit(); |
| 7842 | 7809 | |
| 7843 | | var wip_captures = try WipCaptureScope.init(gpa, sema.owner_decl.src_scope); |
| 7844 | | defer wip_captures.deinit(); |
| 7845 | | |
| 7846 | 7810 | var child_block: Block = .{ |
| 7847 | 7811 | .parent = null, |
| 7848 | 7812 | .sema = &child_sema, |
| 7849 | 7813 | .src_decl = generic_owner_func.owner_decl, |
| 7850 | 7814 | .namespace = namespace_index, |
| 7851 | | .wip_capture_scope = wip_captures.scope, |
| 7815 | .wip_capture_scope = try mod.createCaptureScope(sema.owner_decl.src_scope), |
| 7852 | 7816 | .instructions = .{}, |
| 7853 | 7817 | .inlining = null, |
| 7854 | 7818 | .is_comptime = true, |
| ... | ... | @@ -8000,8 +7964,6 @@ fn instantiateGenericCall( |
| 8000 | 7964 | const func_ty = callee.ty.toType(); |
| 8001 | 7965 | const func_ty_info = mod.typeToFunc(func_ty).?; |
| 8002 | 7966 | |
| 8003 | | try wip_captures.finalize(); |
| 8004 | | |
| 8005 | 7967 | // If the call evaluated to a return type that requires comptime, never mind |
| 8006 | 7968 | // our generic instantiation. Instead we need to perform a comptime call. |
| 8007 | 7969 | if (try sema.typeRequiresComptime(func_ty_info.return_type.toType())) { |
| ... | ... | @@ -11897,11 +11859,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11897 | 11859 | const body = sema.code.extra[extra_index..][0..info.body_len]; |
| 11898 | 11860 | extra_index += info.body_len; |
| 11899 | 11861 | |
| 11900 | | var wip_captures = try WipCaptureScope.init(gpa, child_block.wip_capture_scope); |
| 11901 | | defer wip_captures.deinit(); |
| 11902 | | |
| 11903 | 11862 | case_block.instructions.shrinkRetainingCapacity(0); |
| 11904 | | case_block.wip_capture_scope = wip_captures.scope; |
| 11863 | case_block.wip_capture_scope = try mod.createCaptureScope(child_block.wip_capture_scope); |
| 11905 | 11864 | |
| 11906 | 11865 | const item = case_vals.items[scalar_i]; |
| 11907 | 11866 | // `item` is already guaranteed to be constant known. |
| ... | ... | @@ -11929,8 +11888,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11929 | 11888 | _ = try case_block.addNoOp(.unreach); |
| 11930 | 11889 | } |
| 11931 | 11890 | |
| 11932 | | try wip_captures.finalize(); |
| 11933 | | |
| 11934 | 11891 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); |
| 11935 | 11892 | cases_extra.appendAssumeCapacity(1); // items_len |
| 11936 | 11893 | cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len)); |
| ... | ... | @@ -12177,11 +12134,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12177 | 12134 | var cond_body = try case_block.instructions.toOwnedSlice(gpa); |
| 12178 | 12135 | defer gpa.free(cond_body); |
| 12179 | 12136 | |
| 12180 | | var wip_captures = try WipCaptureScope.init(gpa, child_block.wip_capture_scope); |
| 12181 | | defer wip_captures.deinit(); |
| 12182 | | |
| 12183 | 12137 | case_block.instructions.shrinkRetainingCapacity(0); |
| 12184 | | case_block.wip_capture_scope = wip_captures.scope; |
| 12138 | case_block.wip_capture_scope = try mod.createCaptureScope(child_block.wip_capture_scope); |
| 12185 | 12139 | |
| 12186 | 12140 | const body = sema.code.extra[extra_index..][0..info.body_len]; |
| 12187 | 12141 | extra_index += info.body_len; |
| ... | ... | @@ -12200,8 +12154,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12200 | 12154 | ); |
| 12201 | 12155 | } |
| 12202 | 12156 | |
| 12203 | | try wip_captures.finalize(); |
| 12204 | | |
| 12205 | 12157 | if (is_first) { |
| 12206 | 12158 | is_first = false; |
| 12207 | 12159 | first_else_body = cond_body; |
| ... | ... | @@ -12407,11 +12359,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12407 | 12359 | }), |
| 12408 | 12360 | }; |
| 12409 | 12361 | |
| 12410 | | var wip_captures = try WipCaptureScope.init(gpa, child_block.wip_capture_scope); |
| 12411 | | defer wip_captures.deinit(); |
| 12412 | | |
| 12413 | 12362 | case_block.instructions.shrinkRetainingCapacity(0); |
| 12414 | | case_block.wip_capture_scope = wip_captures.scope; |
| 12363 | case_block.wip_capture_scope = try mod.createCaptureScope(child_block.wip_capture_scope); |
| 12415 | 12364 | |
| 12416 | 12365 | if (mod.backendSupportsFeature(.is_named_enum_value) and special.body.len != 0 and block.wantSafety() and |
| 12417 | 12366 | operand_ty.zigTypeTag(mod) == .Enum and (!operand_ty.isNonexhaustiveEnum(mod) or union_originally)) |
| ... | ... | @@ -12456,8 +12405,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12456 | 12405 | } |
| 12457 | 12406 | } |
| 12458 | 12407 | |
| 12459 | | try wip_captures.finalize(); |
| 12460 | | |
| 12461 | 12408 | if (is_first) { |
| 12462 | 12409 | final_else_body = case_block.instructions.items; |
| 12463 | 12410 | } else { |
| ... | ... | @@ -16557,51 +16504,53 @@ fn zirThis( |
| 16557 | 16504 | } |
| 16558 | 16505 | |
| 16559 | 16506 | fn zirClosureCapture(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 16507 | const mod = sema.mod; |
| 16508 | const gpa = sema.gpa; |
| 16560 | 16509 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; |
| 16561 | 16510 | // Closures are not necessarily constant values. For example, the |
| 16562 | 16511 | // code might do something like this: |
| 16563 | 16512 | // fn foo(x: anytype) void { const S = struct {field: @TypeOf(x)}; } |
| 16564 | 16513 | // ...in which case the closure_capture instruction has access to a runtime |
| 16565 | | // value only. In such case we preserve the type and use a dummy runtime value. |
| 16514 | // value only. In such case only the type is saved into the scope. |
| 16566 | 16515 | const operand = try sema.resolveInst(inst_data.operand); |
| 16567 | 16516 | const ty = sema.typeOf(operand); |
| 16568 | | const capture: CaptureScope.Capture = blk: { |
| 16569 | | if (try sema.resolveMaybeUndefValAllowVariables(operand)) |val| { |
| 16570 | | const ip_index = try val.intern(ty, sema.mod); |
| 16571 | | break :blk .{ .comptime_val = ip_index }; |
| 16572 | | } |
| 16573 | | break :blk .{ .runtime_val = ty.toIntern() }; |
| 16517 | const key: CaptureScope.Key = .{ |
| 16518 | .zir_index = inst, |
| 16519 | .index = block.wip_capture_scope, |
| 16574 | 16520 | }; |
| 16575 | | try block.wip_capture_scope.captures.putNoClobber(sema.gpa, inst, capture); |
| 16521 | if (try sema.resolveMaybeUndefValAllowVariables(operand)) |val| { |
| 16522 | try mod.comptime_capture_scopes.put(gpa, key, try val.intern(ty, mod)); |
| 16523 | } else { |
| 16524 | try mod.runtime_capture_scopes.put(gpa, key, ty.toIntern()); |
| 16525 | } |
| 16576 | 16526 | } |
| 16577 | 16527 | |
| 16578 | 16528 | fn zirClosureGet(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 16579 | 16529 | const mod = sema.mod; |
| 16580 | | const ip = &mod.intern_pool; |
| 16530 | //const ip = &mod.intern_pool; |
| 16581 | 16531 | const inst_data = sema.code.instructions.items(.data)[inst].inst_node; |
| 16582 | | var scope: *CaptureScope = mod.declPtr(block.src_decl).src_scope.?; |
| 16532 | var scope: CaptureScope.Index = mod.declPtr(block.src_decl).src_scope; |
| 16533 | assert(scope != .none); |
| 16583 | 16534 | // Note: The target closure must be in this scope list. |
| 16584 | 16535 | // If it's not here, the zir is invalid, or the list is broken. |
| 16585 | | const capture = while (true) { |
| 16536 | const capture_ty = while (true) { |
| 16586 | 16537 | // Note: We don't need to add a dependency here, because |
| 16587 | 16538 | // decls always depend on their lexical parents. |
| 16588 | | |
| 16589 | | // Fail this decl if a scope it depended on failed. |
| 16590 | | if (scope.failed()) { |
| 16591 | | if (sema.owner_func_index != .none) { |
| 16592 | | ip.funcAnalysis(sema.owner_func_index).state = .dependency_failure; |
| 16593 | | } else { |
| 16594 | | sema.owner_decl.analysis = .dependency_failure; |
| 16595 | | } |
| 16596 | | return error.AnalysisFail; |
| 16597 | | } |
| 16598 | | if (scope.captures.get(inst_data.inst)) |capture| { |
| 16599 | | break capture; |
| 16600 | | } |
| 16601 | | scope = scope.parent.?; |
| 16539 | const key: CaptureScope.Key = .{ |
| 16540 | .zir_index = inst_data.inst, |
| 16541 | .index = scope, |
| 16542 | }; |
| 16543 | if (mod.comptime_capture_scopes.get(key)) |val| |
| 16544 | return Air.internedToRef(val); |
| 16545 | if (mod.runtime_capture_scopes.get(key)) |ty| |
| 16546 | break ty; |
| 16547 | scope = scope.parent(mod); |
| 16548 | assert(scope != .none); |
| 16602 | 16549 | }; |
| 16603 | 16550 | |
| 16604 | | if (capture == .runtime_val and !block.is_typeof and sema.func_index == .none) { |
| 16551 | // The comptime case is handled already above. Runtime case below. |
| 16552 | |
| 16553 | if (!block.is_typeof and sema.func_index == .none) { |
| 16605 | 16554 | const msg = msg: { |
| 16606 | 16555 | const name = name: { |
| 16607 | 16556 | const file = sema.owner_decl.getFileScope(mod); |
| ... | ... | @@ -16629,7 +16578,7 @@ fn zirClosureGet(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 16629 | 16578 | return sema.failWithOwnedErrorMsg(block, msg); |
| 16630 | 16579 | } |
| 16631 | 16580 | |
| 16632 | | if (capture == .runtime_val and !block.is_typeof and !block.is_comptime and sema.func_index != .none) { |
| 16581 | if (!block.is_typeof and !block.is_comptime and sema.func_index != .none) { |
| 16633 | 16582 | const msg = msg: { |
| 16634 | 16583 | const name = name: { |
| 16635 | 16584 | const file = sema.owner_decl.getFileScope(mod); |
| ... | ... | @@ -16659,16 +16608,9 @@ fn zirClosureGet(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 16659 | 16608 | return sema.failWithOwnedErrorMsg(block, msg); |
| 16660 | 16609 | } |
| 16661 | 16610 | |
| 16662 | | switch (capture) { |
| 16663 | | .runtime_val => |ty_ip_index| { |
| 16664 | | assert(block.is_typeof); |
| 16665 | | // We need a dummy runtime instruction with the correct type. |
| 16666 | | return block.addTy(.alloc, ty_ip_index.toType()); |
| 16667 | | }, |
| 16668 | | .comptime_val => |val_ip_index| { |
| 16669 | | return Air.internedToRef(val_ip_index); |
| 16670 | | }, |
| 16671 | | } |
| 16611 | assert(block.is_typeof); |
| 16612 | // We need a dummy runtime instruction with the correct type. |
| 16613 | return block.addTy(.alloc, capture_ty.toType()); |
| 16672 | 16614 | } |
| 16673 | 16615 | |
| 16674 | 16616 | fn zirRetAddr( |
| ... | ... | @@ -24988,7 +24930,7 @@ fn zirBuiltinExtern( |
| 24988 | 24930 | |
| 24989 | 24931 | // TODO check duplicate extern |
| 24990 | 24932 | |
| 24991 | | const new_decl_index = try mod.allocateNewDecl(sema.owner_decl.src_namespace, sema.owner_decl.src_node, null); |
| 24933 | const new_decl_index = try mod.allocateNewDecl(sema.owner_decl.src_namespace, sema.owner_decl.src_node, .none); |
| 24992 | 24934 | errdefer mod.destroyDecl(new_decl_index); |
| 24993 | 24935 | const new_decl = mod.declPtr(new_decl_index); |
| 24994 | 24936 | new_decl.name = options.name; |
| ... | ... | @@ -34327,15 +34269,12 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi |
| 34327 | 34269 | }; |
| 34328 | 34270 | defer sema.deinit(); |
| 34329 | 34271 | |
| 34330 | | var wip_captures = try WipCaptureScope.init(gpa, decl.src_scope); |
| 34331 | | defer wip_captures.deinit(); |
| 34332 | | |
| 34333 | 34272 | var block: Block = .{ |
| 34334 | 34273 | .parent = null, |
| 34335 | 34274 | .sema = &sema, |
| 34336 | 34275 | .src_decl = decl_index, |
| 34337 | 34276 | .namespace = struct_obj.namespace, |
| 34338 | | .wip_capture_scope = wip_captures.scope, |
| 34277 | .wip_capture_scope = try mod.createCaptureScope(decl.src_scope), |
| 34339 | 34278 | .instructions = .{}, |
| 34340 | 34279 | .inlining = null, |
| 34341 | 34280 | .is_comptime = true, |
| ... | ... | @@ -34356,7 +34295,6 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi |
| 34356 | 34295 | |
| 34357 | 34296 | try sema.checkBackingIntType(&block, backing_int_src, backing_int_ty, fields_bit_sum); |
| 34358 | 34297 | struct_obj.backing_int_ty = backing_int_ty; |
| 34359 | | try wip_captures.finalize(); |
| 34360 | 34298 | for (comptime_mutable_decls.items) |ct_decl_index| { |
| 34361 | 34299 | const ct_decl = mod.declPtr(ct_decl_index); |
| 34362 | 34300 | _ = try ct_decl.internValue(mod); |
| ... | ... | @@ -35018,15 +34956,12 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void |
| 35018 | 34956 | }; |
| 35019 | 34957 | defer sema.deinit(); |
| 35020 | 34958 | |
| 35021 | | var wip_captures = try WipCaptureScope.init(gpa, decl.src_scope); |
| 35022 | | defer wip_captures.deinit(); |
| 35023 | | |
| 35024 | 34959 | var block_scope: Block = .{ |
| 35025 | 34960 | .parent = null, |
| 35026 | 34961 | .sema = &sema, |
| 35027 | 34962 | .src_decl = decl_index, |
| 35028 | 34963 | .namespace = struct_obj.namespace, |
| 35029 | | .wip_capture_scope = wip_captures.scope, |
| 34964 | .wip_capture_scope = try mod.createCaptureScope(decl.src_scope), |
| 35030 | 34965 | .instructions = .{}, |
| 35031 | 34966 | .inlining = null, |
| 35032 | 34967 | .is_comptime = true, |
| ... | ... | @@ -35283,7 +35218,6 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void |
| 35283 | 35218 | } |
| 35284 | 35219 | } |
| 35285 | 35220 | } |
| 35286 | | try wip_captures.finalize(); |
| 35287 | 35221 | for (comptime_mutable_decls.items) |ct_decl_index| { |
| 35288 | 35222 | const ct_decl = mod.declPtr(ct_decl_index); |
| 35289 | 35223 | _ = try ct_decl.internValue(mod); |
| ... | ... | @@ -35361,15 +35295,12 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Key.Un |
| 35361 | 35295 | }; |
| 35362 | 35296 | defer sema.deinit(); |
| 35363 | 35297 | |
| 35364 | | var wip_captures = try WipCaptureScope.init(gpa, decl.src_scope); |
| 35365 | | defer wip_captures.deinit(); |
| 35366 | | |
| 35367 | 35298 | var block_scope: Block = .{ |
| 35368 | 35299 | .parent = null, |
| 35369 | 35300 | .sema = &sema, |
| 35370 | 35301 | .src_decl = decl_index, |
| 35371 | 35302 | .namespace = union_type.namespace, |
| 35372 | | .wip_capture_scope = wip_captures.scope, |
| 35303 | .wip_capture_scope = try mod.createCaptureScope(decl.src_scope), |
| 35373 | 35304 | .instructions = .{}, |
| 35374 | 35305 | .inlining = null, |
| 35375 | 35306 | .is_comptime = true, |
| ... | ... | @@ -35380,7 +35311,6 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Key.Un |
| 35380 | 35311 | try sema.analyzeBody(&block_scope, body); |
| 35381 | 35312 | } |
| 35382 | 35313 | |
| 35383 | | try wip_captures.finalize(); |
| 35384 | 35314 | for (comptime_mutable_decls.items) |ct_decl_index| { |
| 35385 | 35315 | const ct_decl = mod.declPtr(ct_decl_index); |
| 35386 | 35316 | _ = try ct_decl.internValue(mod); |
| ... | ... | @@ -35823,18 +35753,16 @@ fn generateUnionTagTypeSimple( |
| 35823 | 35753 | } |
| 35824 | 35754 | |
| 35825 | 35755 | fn getBuiltin(sema: *Sema, name: []const u8) CompileError!Air.Inst.Ref { |
| 35756 | const mod = sema.mod; |
| 35826 | 35757 | const gpa = sema.gpa; |
| 35827 | 35758 | const src = LazySrcLoc.nodeOffset(0); |
| 35828 | 35759 | |
| 35829 | | var wip_captures = try WipCaptureScope.init(gpa, sema.owner_decl.src_scope); |
| 35830 | | defer wip_captures.deinit(); |
| 35831 | | |
| 35832 | 35760 | var block: Block = .{ |
| 35833 | 35761 | .parent = null, |
| 35834 | 35762 | .sema = sema, |
| 35835 | 35763 | .src_decl = sema.owner_decl_index, |
| 35836 | 35764 | .namespace = sema.owner_decl.src_namespace, |
| 35837 | | .wip_capture_scope = wip_captures.scope, |
| 35765 | .wip_capture_scope = try mod.createCaptureScope(sema.owner_decl.src_scope), |
| 35838 | 35766 | .instructions = .{}, |
| 35839 | 35767 | .inlining = null, |
| 35840 | 35768 | .is_comptime = true, |
| ... | ... | @@ -35875,17 +35803,15 @@ fn getBuiltinDecl(sema: *Sema, block: *Block, name: []const u8) CompileError!Mod |
| 35875 | 35803 | } |
| 35876 | 35804 | |
| 35877 | 35805 | fn getBuiltinType(sema: *Sema, name: []const u8) CompileError!Type { |
| 35806 | const mod = sema.mod; |
| 35878 | 35807 | const ty_inst = try sema.getBuiltin(name); |
| 35879 | 35808 | |
| 35880 | | var wip_captures = try WipCaptureScope.init(sema.gpa, sema.owner_decl.src_scope); |
| 35881 | | defer wip_captures.deinit(); |
| 35882 | | |
| 35883 | 35809 | var block: Block = .{ |
| 35884 | 35810 | .parent = null, |
| 35885 | 35811 | .sema = sema, |
| 35886 | 35812 | .src_decl = sema.owner_decl_index, |
| 35887 | 35813 | .namespace = sema.owner_decl.src_namespace, |
| 35888 | | .wip_capture_scope = wip_captures.scope, |
| 35814 | .wip_capture_scope = try mod.createCaptureScope(sema.owner_decl.src_scope), |
| 35889 | 35815 | .instructions = .{}, |
| 35890 | 35816 | .inlining = null, |
| 35891 | 35817 | .is_comptime = true, |