luaur-analysis 0.1.1

Luau type checker and type inference (Rust).
Documentation
use crate::functions::get_type_alt_j::get_type_id;
use crate::records::boolean_singleton::BooleanSingleton;
use crate::records::never_type::NeverType;
use crate::records::normalizer::Normalizer;
use crate::records::singleton_type::SingletonType;
use crate::type_aliases::type_id::TypeId;

impl Normalizer {
    pub fn intersection_of_bools(&mut self, here: TypeId, there: TypeId) -> TypeId {
        self.consume_fuel();

        if !unsafe { get_type_id::<NeverType>(here).is_null() } {
            return here;
        }
        if !unsafe { get_type_id::<NeverType>(there).is_null() } {
            return there;
        }

        if let Some(hbool) = unsafe {
            get_type_id::<SingletonType>(here)
                .as_ref()
                .and_then(|s| s.variant.get_if::<BooleanSingleton>())
        } {
            if let Some(tbool) = unsafe {
                get_type_id::<SingletonType>(there)
                    .as_ref()
                    .and_then(|s| s.variant.get_if::<BooleanSingleton>())
            } {
                if hbool.value == tbool.value {
                    return here;
                } else {
                    return unsafe { (*self.builtin_types).neverType };
                }
            }

            return here;
        }

        there
    }
}