pub struct Typecheck<'a, 'ast> { /* private fields */ }
Expand description

Struct which provides methods to typecheck expressions.

Implementations§

source§

impl<'a, 'ast> Typecheck<'a, 'ast>

source

pub fn new( module: String, symbols: &'a mut Symbols, environment: &'a (dyn TypecheckEnv<Type = ArcType> + 'a), interner: &TypeCache<Symbol, ArcType>, metadata: &'a mut FnvMap<Symbol, Arc<Metadata>>, ast_arena: ArenaRef<'a, 'ast, Symbol> ) -> Self

Create a new typechecker which typechecks expressions in module

source

pub fn typecheck_expr( &mut self, expr: &mut SpannedExpr<'ast, Symbol> ) -> Result<ArcType, Error>

Typecheck expr. If successful the type of the expression will be returned and all identifiers in expr will be filled with the inferred type

source

pub fn typecheck_expr_expected( &mut self, expr: &mut SpannedExpr<'ast, Symbol>, expected_type: Option<&ArcType> ) -> Result<ArcType, Error>

Trait Implementations§

source§

impl<'a> TypeContext<Symbol, ArcType> for Typecheck<'a, '_>

source§

fn intern(&mut self, typ: Type<Symbol, RcType>) -> RcType

source§

fn intern_types( &mut self, types: impl IntoIterator<Item = RcType> ) -> <RcType as TypePtr>::Types

source§

fn intern_generics( &mut self, types: impl IntoIterator<Item = Generic<Symbol>> ) -> <RcType as TypePtr>::Generics

source§

fn intern_fields( &mut self, types: impl IntoIterator<Item = Field<<RcType as TypePtr>::SpannedId, RcType>> ) -> <RcType as TypePtr>::Fields

source§

fn intern_type_fields( &mut self, types: impl IntoIterator<Item = Field<<RcType as TypePtr>::SpannedId, Alias<Symbol, RcType>>> ) -> <RcType as TypePtr>::TypeFields

source§

fn intern_flags(&mut self, typ: Type<Symbol, RcType>, flags: Flags) -> RcType

source§

fn builtin(&mut self, typ: BuiltinType) -> RcType

source§

fn forall( &mut self, params: <RcType as TypePtr>::Generics, typ: RcType ) -> RcType

source§

fn with_forall(&mut self, typ: RcType, from: &RcType) -> RcType

source§

fn array(&mut self, typ: RcType) -> RcType

source§

fn app(&mut self, id: RcType, args: <RcType as TypePtr>::Types) -> RcType

source§

fn variant(&mut self, fields: <RcType as TypePtr>::Fields) -> RcType

source§

fn poly_variant( &mut self, fields: <RcType as TypePtr>::Fields, rest: RcType ) -> RcType

source§

fn effect(&mut self, fields: <RcType as TypePtr>::Fields) -> RcType

source§

fn poly_effect( &mut self, fields: <RcType as TypePtr>::Fields, rest: RcType ) -> RcType

source§

fn record( &mut self, types: <RcType as TypePtr>::TypeFields, fields: <RcType as TypePtr>::Fields ) -> RcType

source§

fn poly_record( &mut self, types: <RcType as TypePtr>::TypeFields, fields: <RcType as TypePtr>::Fields, rest: RcType ) -> RcType

source§

fn extend_full_row( &mut self, types: <RcType as TypePtr>::TypeFields, fields: <RcType as TypePtr>::Fields, rest: RcType ) -> RcType

source§

fn extend_row( &mut self, fields: <RcType as TypePtr>::Fields, rest: RcType ) -> RcType

source§

fn extend_type_row( &mut self, types: <RcType as TypePtr>::TypeFields, rest: RcType ) -> RcType

source§

fn generic(&mut self, typ: Generic<Symbol>) -> RcType

source§

fn skolem(&mut self, typ: Skolem<Symbol>) -> RcType

source§

fn variable(&mut self, typ: TypeVariable) -> RcType

source§

fn alias( &mut self, name: Symbol, args: <RcType as TypePtr>::Generics, typ: RcType ) -> RcType

source§

fn ident(&mut self, id: KindedIdent<Symbol>) -> RcType

source§

fn projection(&mut self, id: AppVec<Symbol>) -> RcType

source§

fn builtin_type(&mut self, typ: BuiltinType) -> RcType

source§

fn new_alias( &mut self, name: Symbol, args: <RcType as TypePtr>::Generics, typ: RcType ) -> Alias<Symbol, RcType>

source§

fn new_data_alias( &mut self, data: AliasData<Symbol, RcType> ) -> Alias<Symbol, RcType>

source§

fn alias_group( &mut self, group: Vec<AliasData<Symbol, RcType>> ) -> Vec<Alias<Symbol, RcType>>

source§

fn hole(&mut self) -> RcType

source§

fn opaque(&mut self) -> RcType

source§

fn error(&mut self) -> RcType

source§

fn array_builtin(&mut self) -> RcType

source§

fn empty_row(&mut self) -> RcType

source§

fn function_builtin(&mut self) -> RcType

source§

fn string(&mut self) -> RcType

source§

fn char(&mut self) -> RcType

source§

fn byte(&mut self) -> RcType

source§

fn int(&mut self) -> RcType

source§

fn float(&mut self) -> RcType

source§

fn unit(&mut self) -> RcType

source§

fn tuple<S, I>(&mut self, symbols: &mut S, elems: I) -> T
where S: IdentEnv<Ident = Id> + ?Sized, <T as TypePtr>::SpannedId: From<(Id, Span<ByteIndex>)>, I: IntoIterator<Item = T>, T: HasSpan,

source§

fn tuple_<S, I>(&mut self, symbols: &mut S, elems: I) -> Type<Id, T>
where S: IdentEnv<Ident = Id> + ?Sized, <T as TypePtr>::SpannedId: From<(Id, Span<ByteIndex>)>, T: HasSpan, I: IntoIterator<Item = T>,

source§

fn function<I>(&mut self, args: I, ret: T) -> T
where I: IntoIterator<Item = T>, <I as IntoIterator>::IntoIter: DoubleEndedIterator<Item = T>,

source§

fn function_implicit<I>(&mut self, args: I, ret: T) -> T
where I: IntoIterator<Item = T>, <I as IntoIterator>::IntoIter: DoubleEndedIterator<Item = T>,

source§

fn function_type<I>(&mut self, arg_type: ArgType, args: I, ret: T) -> T
where I: IntoIterator<Item = T>, <I as IntoIterator>::IntoIter: DoubleEndedIterator<Item = T>,

Auto Trait Implementations§

§

impl<'a, 'ast> !RefUnwindSafe for Typecheck<'a, 'ast>

§

impl<'a, 'ast> !Send for Typecheck<'a, 'ast>

§

impl<'a, 'ast> !Sync for Typecheck<'a, 'ast>

§

impl<'a, 'ast> Unpin for Typecheck<'a, 'ast>

§

impl<'a, 'ast> !UnwindSafe for Typecheck<'a, 'ast>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<Id> AsId<Id> for Id
where Id: ?Sized,

source§

fn as_id(&self) -> &Id

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Any for T
where T: Any,