class

TypeChecker

Inherits TypeUnifier < TypeEvaluator < CanError < Reference < Object

type inference algorithm

Constructors

new(context : TypeContext, specializer : Specializer)
Source

Instance methods

and_op(left : Hir, right : Hir) : Hir
Source
assign(lhs : Ast::Expr, rhs : Hir) : Hir
Source
check_type(actual : Type, expected : Type, loc : Location, source : Location)
Source
conditional(cond : Ast::Condition, steps : Array(Hir::TestOrBinding), is_expression : Bool)
Source
consequence_statement(ast : Ast::Expr)
Source
consequence_statement(conditionals : Array(Ast::Condition))
Source
context
Source
declare(binding : Binding, dec_type : Hir.class, loc : Location, name : String, value : Cell(Ast::Expr) | Nil = nil) : Hir
Source
emit_error(error : Error)
Source
eval(*args)
Source
field_access(ast : Ast::FieldAccess)
Source
function_call(location : Location, name : String, args : Array(Hir), type_args : Slice(Type) | Nil = nil) : Hir
Source
identifier(location : Location, name : String) : Hir
Source
infer(ast : Ast::Expr) : Hir

transfrom an ast node to hir, inferring its type

Source
infer(ast : Cell(Ast::Expr)) : Hir

transfrom an ast node to hir, inferring its type

Source
infer_block(ast : Ast::Block) : Hir
Source
infer_implicit_bool(ast : Ast::Expr) : Hir
Source
match(lhs : Hir, rhs : Ast::Expr) : Hir
Source
or_op(left : Hir, right : Hir) : Hir
Source
pattern_match(loc : Location, branches : Array(Ast::RTerm), enum_type : EnumDef, is_expression : Bool) : Array(Hir | Nil)
Source
scope
Source
scope=(scope : TypeScope)
Source
specializer
Source
try_function_call(location, func : FunctionDef, type_args : Slice(Type) | Nil, args : Array(Hir)) : OverloadMatch | Error
Source
type_check(ast : Ast::Expr, expected_type : Type, source : Location) : Hir
Source
type_check(ast : Cell(Ast::Expr), expected_type : Type, source : Location) : Hir
Source
type_check_function(function : Function)
Source
type_check_statement(ast : Ast::Expr) : Hir

runs type checker for the ast node, but allows for inconsistent types on branches this is to allow control-flow nodes (eg if blocks) to be used as statements without needing to have a consistent return type in all branches

Source
type_error(location : Location, message : String)
Source

Nested types