pub enum InferredType {
Show 13 variants
Integer,
Float,
String,
Boolean,
Null,
Array(Box<InferredType>),
Object,
Date,
DateTime,
Duration,
Unknown,
Numeric,
Error(String),
}Expand description
Inferred type of an ELO expression
Variants§
Integer
Integer type
Float
Float type
String
String type
Boolean
Boolean type
Null
Null/None type
Array(Box<InferredType>)
Array with element type
Object
Object with field types (simplified - just track it’s an object)
Date
Date type
DateTime
DateTime type
Duration
Duration type
Unknown
Unknown type (when inference fails or type can’t be determined)
Numeric
Any numeric type (integer or float)
Error(String)
Type error - incompatible types
Implementations§
Source§impl InferredType
impl InferredType
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Check if this is a numeric type
Sourcepub fn common_type(a: &InferredType, b: &InferredType) -> InferredType
pub fn common_type(a: &InferredType, b: &InferredType) -> InferredType
Get a common type that’s compatible with both types
Trait Implementations§
Source§impl Clone for InferredType
impl Clone for InferredType
Source§fn clone(&self) -> InferredType
fn clone(&self) -> InferredType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InferredType
impl Debug for InferredType
Source§impl Display for InferredType
impl Display for InferredType
Source§impl PartialEq for InferredType
impl PartialEq for InferredType
Source§impl Visitor<InferredType> for TypeInferenceVisitor
impl Visitor<InferredType> for TypeInferenceVisitor
Source§fn visit_expr(&mut self, expr: &Expr) -> InferredType
fn visit_expr(&mut self, expr: &Expr) -> InferredType
Visit a generic expression, dispatching to specific methods
Source§fn visit_literal(&mut self, lit: &Literal) -> InferredType
fn visit_literal(&mut self, lit: &Literal) -> InferredType
Visit a literal value (number or boolean)
Source§fn visit_null(&mut self) -> InferredType
fn visit_null(&mut self) -> InferredType
Visit a null literal
Source§fn visit_identifier(&mut self, _name: &str) -> InferredType
fn visit_identifier(&mut self, _name: &str) -> InferredType
Visit an identifier (variable reference)
Source§fn visit_field_access(&mut self, _receiver: &Expr, _field: &str) -> InferredType
fn visit_field_access(&mut self, _receiver: &Expr, _field: &str) -> InferredType
Visit a field access expression
Source§fn visit_binary_op(
&mut self,
op: BinaryOperator,
left: &Expr,
right: &Expr,
) -> InferredType
fn visit_binary_op( &mut self, op: BinaryOperator, left: &Expr, right: &Expr, ) -> InferredType
Visit a binary operation
Source§fn visit_unary_op(&mut self, op: UnaryOperator, operand: &Expr) -> InferredType
fn visit_unary_op(&mut self, op: UnaryOperator, operand: &Expr) -> InferredType
Visit a unary operation
Source§fn visit_function_call(&mut self, name: &str, args: &[Expr]) -> InferredType
fn visit_function_call(&mut self, name: &str, args: &[Expr]) -> InferredType
Visit a function call
Source§fn visit_lambda(&mut self, _param: &str, _body: &Expr) -> InferredType
fn visit_lambda(&mut self, _param: &str, _body: &Expr) -> InferredType
Visit a lambda expression
Source§fn visit_let(&mut self, _name: &str, _value: &Expr, body: &Expr) -> InferredType
fn visit_let(&mut self, _name: &str, _value: &Expr, body: &Expr) -> InferredType
Visit a let binding
Source§fn visit_if(
&mut self,
_condition: &Expr,
then_branch: &Expr,
else_branch: &Expr,
) -> InferredType
fn visit_if( &mut self, _condition: &Expr, then_branch: &Expr, else_branch: &Expr, ) -> InferredType
Visit an if conditional
Source§fn visit_array(&mut self, elements: &[Expr]) -> InferredType
fn visit_array(&mut self, elements: &[Expr]) -> InferredType
Visit an array literal
Source§fn visit_object(&mut self, _fields: &[(String, Expr)]) -> InferredType
fn visit_object(&mut self, _fields: &[(String, Expr)]) -> InferredType
Visit an object literal
Source§fn visit_pipe(&mut self, value: &Expr, functions: &[Expr]) -> InferredType
fn visit_pipe(&mut self, value: &Expr, functions: &[Expr]) -> InferredType
Visit a pipe operator
Source§fn visit_alternative(
&mut self,
primary: &Expr,
alternative: &Expr,
) -> InferredType
fn visit_alternative( &mut self, primary: &Expr, alternative: &Expr, ) -> InferredType
Visit an alternative operator (?|)
Source§fn visit_guard(&mut self, _condition: &Expr, body: &Expr) -> InferredType
fn visit_guard(&mut self, _condition: &Expr, body: &Expr) -> InferredType
Visit a guard expression
Source§fn visit_date(&mut self, _date: &str) -> InferredType
fn visit_date(&mut self, _date: &str) -> InferredType
Visit a date literal
Source§fn visit_datetime(&mut self, _datetime: &str) -> InferredType
fn visit_datetime(&mut self, _datetime: &str) -> InferredType
Visit a datetime literal
Source§fn visit_duration(&mut self, _duration: &str) -> InferredType
fn visit_duration(&mut self, _duration: &str) -> InferredType
Visit a duration literal
Source§fn visit_temporal_keyword(&mut self, _keyword: TemporalKeyword) -> InferredType
fn visit_temporal_keyword(&mut self, _keyword: TemporalKeyword) -> InferredType
Visit a temporal keyword
Source§fn visit_string(&mut self, _value: &str) -> InferredType
fn visit_string(&mut self, _value: &str) -> InferredType
Visit a string literal
impl Eq for InferredType
impl StructuralPartialEq for InferredType
Auto Trait Implementations§
impl Freeze for InferredType
impl RefUnwindSafe for InferredType
impl Send for InferredType
impl Sync for InferredType
impl Unpin for InferredType
impl UnwindSafe for InferredType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more