Skip to main content

luaur_analysis/methods/
unifier_try_unify_with_any_unifier_alt_b.rs

1use crate::functions::get_type_pack::get_type_pack_id;
2use crate::functions::queue_type_pack::queue_type_pack;
3use crate::functions::try_unify_with_any::try_unify_with_any;
4use crate::records::unifier::Unifier;
5use crate::type_aliases::error_type_pack::ErrorTypePack;
6use crate::type_aliases::type_id::TypeId;
7use crate::type_aliases::type_pack_id::TypePackId;
8use alloc::vec::Vec;
9use luaur_common::macros::luau_assert::LUAU_ASSERT;
10
11impl Unifier {
12    pub fn try_unify_with_any_type_pack_id_type_pack_id(
13        &mut self,
14        sub_ty: TypePackId,
15        any_tp: TypePackId,
16    ) {
17        LUAU_ASSERT!(!unsafe { get_type_pack_id::<ErrorTypePack>(any_tp) }.is_null());
18
19        let any_ty: TypeId = unsafe { (*self.builtin_types).errorType };
20        let mut queue: Vec<TypeId> = Vec::new();
21
22        unsafe {
23            let shared_state = &mut *self.shared_state;
24            shared_state.temp_seen_ty.clear();
25            shared_state.temp_seen_tp.clear();
26            let seen_ty = &mut shared_state.temp_seen_ty as *mut _;
27            let seen_tp = &mut shared_state.temp_seen_tp as *mut _;
28
29            queue_type_pack(&mut queue, &mut *seen_tp, self, sub_ty, any_tp);
30            try_unify_with_any(
31                &mut queue,
32                self,
33                &mut *seen_ty,
34                &mut *seen_tp,
35                self.types,
36                any_ty,
37                any_tp,
38            );
39        }
40    }
41}