luaur_analysis/methods/
weird_iter_grow.rs1use crate::functions::get_mutable_type_pack::get_mutable_type_pack_id;
2use crate::records::free_type_pack::FreeTypePack;
3use crate::records::type_pack::TypePack;
4use crate::records::type_pack_var::TypePackVar;
5use crate::records::weird_iter::WeirdIter;
6use crate::type_aliases::type_pack_id::TypePackId;
7use crate::type_aliases::type_pack_variant::TypePackVariant;
8use luaur_common::macros::luau_assert::LUAU_ASSERT;
9
10impl WeirdIter {
11 pub fn weird_iter_grow(&mut self, new_tail: TypePackId) {
12 LUAU_ASSERT!(self.weird_iter_can_grow());
13 LUAU_ASSERT!(!unsafe { get_mutable_type_pack_id::<TypePack>(new_tail) }.is_null());
14
15 let free_pack = unsafe { get_mutable_type_pack_id::<FreeTypePack>(self.pack_id) };
16 self.level = unsafe { (*free_pack).level };
17 if !unsafe { (*free_pack).scope }.is_null() {
18 self.scope = unsafe { (*free_pack).scope };
19 }
20 unsafe {
21 (*self.log).replace_type_pack_id_type_pack_var(
22 self.pack_id,
23 TypePackVar {
24 ty: TypePackVariant::Bound(new_tail),
25 persistent: false,
26 owningArena: core::ptr::null_mut(),
27 },
28 );
29 }
30 self.pack_id = new_tail;
31 self.pack = unsafe { get_mutable_type_pack_id::<TypePack>(new_tail) };
32 self.index = 0;
33 self.growing = true;
34 }
35}