pub struct TypeInferenceEngine {
pub env: TypeEnvironment,
/* private fields */
}Fields§
§env: TypeEnvironmentType environment tracking variable types
Implementations§
Source§impl TypeInferenceEngine
impl TypeInferenceEngine
Sourcepub fn check_expr(&mut self, expr: &Expr, mode: CheckMode) -> TypeResult<Type>
pub fn check_expr(&mut self, expr: &Expr, mode: CheckMode) -> TypeResult<Type>
Check an expression with a given mode
This is the main entry point for bidirectional type checking.
Sourcepub fn check_against(
&mut self,
expr: &Expr,
expected: &Type,
) -> TypeResult<Type>
pub fn check_against( &mut self, expr: &Expr, expected: &Type, ) -> TypeResult<Type>
Check an expression against an expected type
The expected type guides inference and provides better error messages.
Source§impl TypeInferenceEngine
impl TypeInferenceEngine
Sourcepub fn infer_expr(&mut self, expr: &Expr) -> TypeResult<Type>
pub fn infer_expr(&mut self, expr: &Expr) -> TypeResult<Type>
Infer type of an expression
Source§impl TypeInferenceEngine
impl TypeInferenceEngine
pub fn new() -> Self
Sourcepub fn register_known_bindings(&mut self, names: &[String])
pub fn register_known_bindings(&mut self, names: &[String])
Register host-known root-scope bindings before program inference.
These names come from host configuration (project/frontmatter/extensions) and prevent false-positive “undefined variable” diagnostics in the shared analyzer.
pub fn find_origin_for_unsolved_constraints( &self, constraints: &[(Type, Type)], ) -> Option<Span>
Sourcepub fn resolve_named_to_enum(&self, ty: &SemanticType) -> SemanticType
pub fn resolve_named_to_enum(&self, ty: &SemanticType) -> SemanticType
Resolve a Named type to a full Enum type if the name refers to an enum
This is used for exhaustiveness checking - we need the full enum variant information to verify all cases are covered.
Sourcepub fn run_hoisting_prepass(&mut self, program: &Program)
pub fn run_hoisting_prepass(&mut self, program: &Program)
Infer types for a complete program Run the optimistic hoisting pre-pass
This collects all property assignments (e.g., a.b = 2) and registers
them as hoisted fields so they’re available during the main type checking pass.
Call this BEFORE infer_program or infer_expr for optimistic hoisting to work.
Sourcepub fn infer_program(
&mut self,
program: &Program,
) -> TypeResult<HashMap<String, Type>>
pub fn infer_program( &mut self, program: &Program, ) -> TypeResult<HashMap<String, Type>>
Infer types for a complete program
This runs the hoisting pre-pass automatically before main type inference.
Sourcepub fn infer_program_best_effort(
&mut self,
program: &Program,
) -> (HashMap<String, Type>, Vec<TypeError>)
pub fn infer_program_best_effort( &mut self, program: &Program, ) -> (HashMap<String, Type>, Vec<TypeError>)
Infer types for a complete program and keep successful inferences even when some items fail type checking.
This uses the same inference engine and constraint solver as infer_program
and is intended for tooling surfaces that should avoid guessing.
Sourcepub fn sync_callable_defaults_from_symbol_table(
&mut self,
symbol_table: &SymbolTable,
)
pub fn sync_callable_defaults_from_symbol_table( &mut self, symbol_table: &SymbolTable, )
Rebuild callable default-parameter metadata from the semantic symbol table.
This is used by legacy semantic analysis paths that infer expressions incrementally instead of running whole-program inference.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TypeInferenceEngine
impl RefUnwindSafe for TypeInferenceEngine
impl Send for TypeInferenceEngine
impl Sync for TypeInferenceEngine
impl Unpin for TypeInferenceEngine
impl UnsafeUnpin for TypeInferenceEngine
impl UnwindSafe for TypeInferenceEngine
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more