Commit d881d841ed

Jacob Young <jacobly0@users.noreply.github.com>
2023-06-27 00:49:38
Sema: use tmp_hack_arena as a temporary solution for lifetime issues
All of this code is expected to get rewritten anyway. Closes #16216
1 parent d9e8671
Changed files (1)
src/Sema.zig
@@ -28885,7 +28885,7 @@ fn beginComptimePtrMutation(
                                     // If we wanted to avoid this, there would need to be special detection
                                     // elsewhere to identify when writing a value to an array element that is stored
                                     // using the `bytes` tag, and handle it without making a call to this function.
-                                    const arena = sema.arena;
+                                    const arena = mod.tmp_hack_arena.allocator();
 
                                     const bytes = val_ptr.castTag(.bytes).?.data;
                                     const dest_len = parent.ty.arrayLenIncludingSentinel(mod);
@@ -28917,7 +28917,7 @@ fn beginComptimePtrMutation(
                                     // need to be special detection elsewhere to identify when writing a value to an
                                     // array element that is stored using the `repeated` tag, and handle it
                                     // without making a call to this function.
-                                    const arena = sema.arena;
+                                    const arena = mod.tmp_hack_arena.allocator();
 
                                     const repeated_val = try val_ptr.castTag(.repeated).?.data.intern(parent.ty.childType(mod), mod);
                                     const array_len_including_sentinel =
@@ -28955,7 +28955,7 @@ fn beginComptimePtrMutation(
                                     // An array has been initialized to undefined at comptime and now we
                                     // are for the first time setting an element. We must change the representation
                                     // of the array from `undef` to `array`.
-                                    const arena = sema.arena;
+                                    const arena = mod.tmp_hack_arena.allocator();
 
                                     const array_len_including_sentinel =
                                         try sema.usizeCast(block, src, parent.ty.arrayLenIncludingSentinel(mod));
@@ -29053,7 +29053,7 @@ fn beginComptimePtrMutation(
                             parent.mut_decl,
                         ),
                         .repeated => {
-                            const arena = sema.arena;
+                            const arena = mod.tmp_hack_arena.allocator();
 
                             const elems = try arena.alloc(Value, parent.ty.structFieldCount(mod));
                             @memset(elems, val_ptr.castTag(.repeated).?.data);
@@ -29116,7 +29116,7 @@ fn beginComptimePtrMutation(
                             // A struct or union has been initialized to undefined at comptime and now we
                             // are for the first time setting a field. We must change the representation
                             // of the struct/union from `undef` to `struct`/`union`.
-                            const arena = sema.arena;
+                            const arena = mod.tmp_hack_arena.allocator();
 
                             switch (parent.ty.zigTypeTag(mod)) {
                                 .Struct => {