pub struct TypeChecker {
pub env: TypeEnv,
pub subst: Substitution,
pub diags: DiagnosticBag,
pub impl_table: Option<ImplTable>,
/* private fields */
}Expand description
Fields§
§env: TypeEnvScoped variable / function type environment.
subst: SubstitutionAccumulated type-variable substitution from unification.
diags: DiagnosticBagDiagnostics emitted during type checking.
impl_table: Option<ImplTable>Trait impl table for checking where-clause bounds at call sites.
When None, trait-bound checking is skipped.
Implementations§
Source§impl TypeChecker
impl TypeChecker
Sourcepub fn type_of(&self, id: NodeId) -> Option<&Type>
pub fn type_of(&self, id: NodeId) -> Option<&Type>
Look up the resolved type for node_id from the side-table.
Sourcepub fn record_field_types(&self) -> &HashMap<String, Vec<(String, Type)>>
pub fn record_field_types(&self) -> &HashMap<String, Vec<(String, Type)>>
Record field types: record_name → [(field_name, field_type)].
Sourcepub fn record_generic_params(&self) -> &HashMap<String, Vec<String>>
pub fn record_generic_params(&self) -> &HashMap<String, Vec<String>>
Generic type parameter names for records: record_name → [param_names].
Sourcepub fn effect_op_types(&self) -> &HashMap<String, Vec<(String, Type)>>
pub fn effect_op_types(&self) -> &HashMap<String, Vec<(String, Type)>>
Effect operation types: effect_name → [(op_name, fn_type)].
Sourcepub fn effect_components(&self) -> &HashMap<String, Vec<String>>
pub fn effect_components(&self) -> &HashMap<String, Vec<String>>
Component effects for composite effects: effect_name → [component_name].
Sourcepub fn method_types(&self) -> &HashMap<String, HashMap<String, Type>>
pub fn method_types(&self) -> &HashMap<String, HashMap<String, Type>>
Inherent impl method signatures: type_name → (method_name → fn_type).
Sourcepub fn trait_method_types(&self) -> &HashMap<String, HashMap<String, Type>>
pub fn trait_method_types(&self) -> &HashMap<String, HashMap<String, Type>>
Trait method signatures: trait_name → (method_name → fn_type).
Sourcepub fn type_aliases(&self) -> &HashMap<String, Type>
pub fn type_aliases(&self) -> &HashMap<String, Type>
Type alias mappings: alias_name → underlying type.
Sourcepub fn insert_record_field_types(
&mut self,
name: String,
fields: Vec<(String, Type)>,
)
pub fn insert_record_field_types( &mut self, name: String, fields: Vec<(String, Type)>, )
Insert record field types for an imported record.
Sourcepub fn insert_record_generic_params(
&mut self,
name: String,
params: Vec<String>,
)
pub fn insert_record_generic_params( &mut self, name: String, params: Vec<String>, )
Insert generic parameter names for an imported record/enum.
Sourcepub fn insert_trait_method_types(
&mut self,
name: String,
methods: HashMap<String, Type>,
)
pub fn insert_trait_method_types( &mut self, name: String, methods: HashMap<String, Type>, )
Insert trait method signatures for an imported trait.
Sourcepub fn insert_effect_op_types(&mut self, name: String, ops: Vec<(String, Type)>)
pub fn insert_effect_op_types(&mut self, name: String, ops: Vec<(String, Type)>)
Insert effect operation types for an imported effect.
Sourcepub fn insert_effect_components(
&mut self,
name: String,
components: Vec<String>,
)
pub fn insert_effect_components( &mut self, name: String, components: Vec<String>, )
Insert component effects for an imported composite effect.
Sourcepub fn insert_type_alias(&mut self, name: String, underlying: Type)
pub fn insert_type_alias(&mut self, name: String, underlying: Type)
Insert a type alias for an imported type alias.
Sourcepub fn insert_method_types(
&mut self,
type_name: String,
methods: HashMap<String, Type>,
)
pub fn insert_method_types( &mut self, type_name: String, methods: HashMap<String, Type>, )
Insert method types for an imported type’s inherent impl.
Sourcepub fn seed_imported_generic_fn(&mut self, name: &str, fn_ty: &FnType) -> Type
pub fn seed_imported_generic_fn(&mut self, name: &str, fn_ty: &FnType) -> Type
Seed an imported generic function signature so that each call site
gets fresh TypeVarIds (just like local generic functions).
When a generic function is exported, its type string contains the
original TypeVarIds (e.g. "Fn(?3) -> ?3"). Without an [FnSig]
entry the call-site instantiation logic in the Call handler is
bypassed, causing the first call to bind those vars permanently.
This method re-allocates fresh TypeVarIds, remaps the function
type, stores the remapped type in env, and inserts a matching
[FnSig] into fn_sigs.
Sourcepub fn check_module(&mut self, module: &mut AIRNode)
pub fn check_module(&mut self, module: &mut AIRNode)
Type-check an AIR module, annotating every node with its resolved type.
Performs two sub-passes:
- Collect — gather all top-level function signatures.
- Check — infer/check each top-level item.
Sourcepub fn infer_expr(&mut self, expr: &AIRNode) -> Type
pub fn infer_expr(&mut self, expr: &AIRNode) -> Type
Synthesis (public): query the side-table for the type of an expression node, or re-infer it on a temporary clone if not yet visited.
Callers that have already called check_module should use type_of
to avoid re-inference overhead.
Sourcepub fn check_expr(&mut self, expr: &AIRNode, expected: &Type)
pub fn check_expr(&mut self, expr: &AIRNode, expected: &Type)
Checking (public): verify that expr has the given expected type.
Emits a diagnostic if the types do not unify. Like infer_expr, this
operates on a clone when the node has not yet been visited.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TypeChecker
impl RefUnwindSafe for TypeChecker
impl Send for TypeChecker
impl Sync for TypeChecker
impl Unpin for TypeChecker
impl UnsafeUnpin for TypeChecker
impl UnwindSafe for TypeChecker
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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);