| ... | @@ -6322,11 +6322,12 @@ pub fn populateTestFunctions( | ... | @@ -6322,11 +6322,12 @@ pub fn populateTestFunctions( |
| 6322 | main_progress_node: *std.Progress.Node, | 6322 | main_progress_node: *std.Progress.Node, |
| 6323 | ) !void { | 6323 | ) !void { |
| 6324 | const gpa = mod.gpa; | 6324 | const gpa = mod.gpa; |
| | 6325 | const ip = &mod.intern_pool; |
| 6325 | const builtin_pkg = mod.main_pkg.table.get("builtin").?; | 6326 | const builtin_pkg = mod.main_pkg.table.get("builtin").?; |
| 6326 | const builtin_file = (mod.importPkg(builtin_pkg) catch unreachable).file; | 6327 | const builtin_file = (mod.importPkg(builtin_pkg) catch unreachable).file; |
| 6327 | const root_decl = mod.declPtr(builtin_file.root_decl.unwrap().?); | 6328 | const root_decl = mod.declPtr(builtin_file.root_decl.unwrap().?); |
| 6328 | const builtin_namespace = mod.namespacePtr(root_decl.src_namespace); | 6329 | const builtin_namespace = mod.namespacePtr(root_decl.src_namespace); |
| 6329 | const test_functions_str = try mod.intern_pool.getOrPutString(gpa, "test_functions"); | 6330 | const test_functions_str = try ip.getOrPutString(gpa, "test_functions"); |
| 6330 | const decl_index = builtin_namespace.decls.getKeyAdapted( | 6331 | const decl_index = builtin_namespace.decls.getKeyAdapted( |
| 6331 | test_functions_str, | 6332 | test_functions_str, |
| 6332 | DeclAdapter{ .mod = mod }, | 6333 | DeclAdapter{ .mod = mod }, |
| ... | @@ -6362,7 +6363,9 @@ pub fn populateTestFunctions( | ... | @@ -6362,7 +6363,9 @@ pub fn populateTestFunctions( |
| 6362 | | 6363 | |
| 6363 | for (test_fn_vals, mod.test_functions.keys()) |*test_fn_val, test_decl_index| { | 6364 | for (test_fn_vals, mod.test_functions.keys()) |*test_fn_val, test_decl_index| { |
| 6364 | const test_decl = mod.declPtr(test_decl_index); | 6365 | const test_decl = mod.declPtr(test_decl_index); |
| 6365 | const test_decl_name = mod.intern_pool.stringToSlice(test_decl.name); | 6366 | // Protects test_decl_name from being invalidated during call to intern() below. |
| | 6367 | try ip.string_bytes.ensureUnusedCapacity(gpa, ip.stringToSlice(test_decl.name).len + 10); |
| | 6368 | const test_decl_name = ip.stringToSlice(test_decl.name); |
| 6366 | const test_name_decl_index = n: { | 6369 | const test_name_decl_index = n: { |
| 6367 | const test_name_decl_ty = try mod.arrayType(.{ | 6370 | const test_name_decl_ty = try mod.arrayType(.{ |
| 6368 | .len = test_decl_name.len, | 6371 | .len = test_decl_name.len, |
| ... | @@ -6444,7 +6447,7 @@ pub fn populateTestFunctions( | ... | @@ -6444,7 +6447,7 @@ pub fn populateTestFunctions( |
| 6444 | .addr = .{ .decl = array_decl_index }, | 6447 | .addr = .{ .decl = array_decl_index }, |
| 6445 | .len = (try mod.intValue(Type.usize, mod.test_functions.count())).toIntern(), | 6448 | .len = (try mod.intValue(Type.usize, mod.test_functions.count())).toIntern(), |
| 6446 | } }); | 6449 | } }); |
| 6447 | mod.intern_pool.mutateVarInit(decl.val.toIntern(), new_init); | 6450 | ip.mutateVarInit(decl.val.toIntern(), new_init); |
| 6448 | | 6451 | |
| 6449 | // Since we are replacing the Decl's value we must perform cleanup on the | 6452 | // Since we are replacing the Decl's value we must perform cleanup on the |
| 6450 | // previous value. | 6453 | // previous value. |