#![doc(hidden)]
use crate::values::typing::type_compiled::compiled::TypeCompiled;
use crate::values::Heap;
use crate::values::StarlarkValue;
use crate::values::Value;
#[derive(Debug, thiserror::Error)]
enum TypingMacroRefsError {
#[error("LHS is not a type: `{0}`")]
LhsNotType(String),
}
pub fn starlark_value_bit_or_for_type<'v, S: StarlarkValue<'v>>(
this: &S,
other: Value<'v>,
heap: &'v Heap,
) -> crate::Result<Value<'v>> {
let Some(this) = this.eval_type() else {
let mut repr = String::new();
this.collect_repr(&mut repr);
return Err(crate::Error::new_other(TypingMacroRefsError::LhsNotType(
repr,
)));
};
let this = TypeCompiled::from_ty(&this, heap);
let other = TypeCompiled::new(other, heap)?;
Ok(TypeCompiled::type_any_of_two(this, other, heap).to_inner())
}