class Mint::TypeChecker

Included Modules

Defined in:

type_checker.cr
type_checker/artifacts.cr
type_checker/comparer.cr
type_checker/record.cr
type_checker/static_type_signature.cr
type_checker/type.cr
type_checker/variable.cr
type_checkers/access.cr
type_checkers/argument.cr
type_checkers/arguments.cr
type_checkers/array_literal.cr
type_checkers/await.cr
type_checkers/block.cr
type_checkers/bool_literal.cr
type_checkers/bracket_access.cr
type_checkers/builtin.cr
type_checkers/call.cr
type_checkers/case.cr
type_checkers/case_branch.cr
type_checkers/comment.cr
type_checkers/commented_expression.cr
type_checkers/component.cr
type_checkers/connect.cr
type_checkers/constant.cr
type_checkers/css_definition.cr
type_checkers/css_font_face.cr
type_checkers/css_keyframes.cr
type_checkers/css_nested_at.cr
type_checkers/css_selector.cr
type_checkers/dbg.cr
type_checkers/decode.cr
type_checkers/defer.cr
type_checkers/destructuring.cr
type_checkers/directives/asset.cr
type_checkers/directives/format.cr
type_checkers/directives/highlight.cr
type_checkers/directives/highlight_file.cr
type_checkers/directives/inline.cr
type_checkers/directives/svg.cr
type_checkers/emit.cr
type_checkers/encode.cr
type_checkers/env.cr
type_checkers/field.cr
type_checkers/field_access.cr
type_checkers/for_expression.cr
type_checkers/function.cr
type_checkers/get.cr
type_checkers/here_document.cr
type_checkers/html_attribute.cr
type_checkers/html_component.cr
type_checkers/html_content.cr
type_checkers/html_element.cr
type_checkers/html_fragment.cr
type_checkers/html_style.cr
type_checkers/if.cr
type_checkers/inline_function.cr
type_checkers/interpolation.cr
type_checkers/js.cr
type_checkers/locale.cr
type_checkers/locale_key.cr
type_checkers/map.cr
type_checkers/module.cr
type_checkers/negated_expression.cr
type_checkers/next_call.cr
type_checkers/number_literal.cr
type_checkers/operation.cr
type_checkers/parenthesized_expression.cr
type_checkers/pipe.cr
type_checkers/property.cr
type_checkers/provider.cr
type_checkers/record.cr
type_checkers/record_update.cr
type_checkers/regexp_literal.cr
type_checkers/return_call.cr
type_checkers/route.cr
type_checkers/routes.cr
type_checkers/signal.cr
type_checkers/state.cr
type_checkers/state_setter.cr
type_checkers/statement.cr
type_checkers/store.cr
type_checkers/string_literal.cr
type_checkers/style.cr
type_checkers/suite.cr
type_checkers/test.cr
type_checkers/top_level.cr
type_checkers/tuple_literal.cr
type_checkers/type.cr
type_checkers/type_definition.cr
type_checkers/type_definition_field.cr
type_checkers/type_variable.cr
type_checkers/type_variant.cr
type_checkers/unary_minus.cr
type_checkers/use.cr
type_checkers/variable.cr

Constant Summary

ARRAY = Type.new("Array", [Variable.new("a")] of Checkable)
BOOL = Type.new("Bool")
BOOL_PROMISE = Type.new("Promise", [BOOL] of Checkable)
CSS_PROPERTY_NAMES = {{ (read_file("/srv/crystaldoc.info/github-mint-lang-mint-0.21.0/src/type_checkers/../assets/css_properties")).strip.lines }}
EVENT = Type.new("Html.Event")
EVENT_FUNCTION = Type.new("Function", [EVENT, Variable.new("a")] of Checkable)
EXPOSED_BUILTINS = ["decodeBoolean", "decodeNumber", "decodeString", "decodeArray", "decodeField", "decodeMaybe", "decodeTime", "locale", "normalizeEvent", "createPortal", "testContext", "testRender", "setLocale", "navigate", "compare", "nothing", "just", "err", "ok", "inspect"] of ::String
HTML = Type.new("Html")
HTML_CHILDREN = Type.new("Array", [HTML] of Checkable)
MAP = Type.new("Map", [Variable.new("a"), Variable.new("b")] of Checkable)
MAYBE = Type.new("Maybe", [Variable.new("a")] of Checkable)
MAYBE_PROMISE = Type.new("Promise", [MAYBE] of Checkable)
NUMBER = Type.new("Number")
NUMBER_CHILDREN = Type.new("Array", [NUMBER] of Checkable)
OBJECT = Type.new("Object")
OBJECT_ERROR = Type.new("Object.Error")
REGEXP = Type.new("Regexp")
RESERVED = ["break", "case", "class", "const", "continue", "debugger", "default", "do", "else", "export", "extends", "for", "if", "import", "in", "instanceof", "new", "return", "super", "switch", "throw", "typeof", "var", "while", "yield"] of ::String
RESULT = Type.new("Result", [Variable.new("a"), Variable.new("b")] of Checkable)
SET = Type.new("Set", [Variable.new("a")] of Checkable)
STRING = Type.new("String")
STYLE_MAP = Type.new("Map", [STRING, STRING] of Checkable)
TEST_CONTEXT = Type.new("Test.Context", [Variable.new("a")] of Checkable)
TEST_PROMISE = Type.new("Promise", [TEST_CONTEXT] of Checkable)
TEXT_CHILDREN = Type.new("Array", [STRING] of Checkable)
TIME = Type.new("Time")
VALID_HTML = [NUMBER_CHILDREN, TEXT_CHILDREN, HTML_CHILDREN, NUMBER, STRING, HTML] of Checkable
VALID_IF_TYPES = [MAYBE_PROMISE, VOID_PROMISE, STRING, ARRAY, MAYBE, VOID, HTML] of Checkable
VALID_TEST_TYPES = [TEST_PROMISE, TEST_CONTEXT, BOOL_PROMISE, BOOL] of Checkable
VOID = Type.new("Void")
VOID_FUNCTION = Type.new("Function", [Variable.new("a")] of Checkable)
VOID_PROMISE = Type.new("Promise", [VOID] of Checkable)

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Mint::Helpers

owns?(node : Ast::Node, parent : Ast::Node) : Bool owns?, static?(nodes : Array(Ast::Node)) : Bool
static?(node : Ast::Node | Nil) : Bool
static?
, static_value(nodes : Array(Ast::Node), separator : Char | Nil = nil) : String
static_value(node : Ast::Node | Nil) : String | Nil
static_value

Instance methods inherited from module Mint::Errorable

error!(name : Symbol, &) error!, unreachable!(message : String) unreachable!

Constructor Detail

def self.new(ast : Ast, check_env : Bool = true, check_everything : Bool = true) #

[View source]

Class Method Detail

def self.check(node : Ast) : Artifacts #

[View source]

Instance Method Detail

def add_record(record : Record, node) #

[View source]
def add_record(record, node) #

[View source]

[View source]
def assets(*args, **options) #

[View source]
def assets(*args, **options, &) #

[View source]
def ast(*args, **options) #

[View source]
def ast(*args, **options, &) #

[View source]
def async(*args, **options) #

[View source]
def async(*args, **options, &) #

[View source]
def block #

[View source]
def cache(*args, **options) #

[View source]
def cache(*args, **options, &) #

[View source]
def check(parameters : Array(Ast::Node), names : Array(Ast::TypeVariable), used_parameters : Set(Ast::TypeVariable)) #

[View source]
def check(node : Ast::CaseBranch, condition : Checkable) : Checkable #

[View source]
def check(node : Ast::HtmlAttribute, element : Ast::HtmlFragment) : Checkable #

[View source]
def check(node : Ast::HtmlAttribute, element : Ast::HtmlElement) : Checkable #

[View source]
def check(node : Ast::HtmlAttribute, component : Ast::Component) : Checkable #

[View source]
def check(node : Ast::Access) : Checkable #

Maybe.Just -> Type Variant Maybe.isJust -> Entity function Html.Event.ADD -> Entity Constant (() { { a: "B" }}).a -> Record access


[View source]
def check(node : Ast::Argument) : Checkable #

[View source]
def check(node : Ast::ArrayLiteral) : Checkable #

[View source]
def check(node : Ast::Await) : Checkable #

[View source]
def check(node : Ast::Block) : Checkable #

[View source]
def check(node : Ast::BoolLiteral) : Checkable #

[View source]
def check(node : Ast::BracketAccess) : Checkable #

[View source]
def check(node : Ast::Builtin) : Checkable #

[View source]
def check(node : Ast::Call) #

[View source]
def check(node : Ast::Case) : Checkable #

[View source]
def check(node : Ast::Comment) : Checkable #

[View source]
def check(node : Ast::CommentedExpression) : Checkable #

[View source]
def check(node : Ast::Component) : Checkable #

[View source]
def check(node : Ast::Connect) : Checkable #

[View source]
def check(node : Ast::Constant) : Checkable #

[View source]
def check(node : Ast::CssDefinition) : Checkable #

[View source]
def check(node : Ast::CssFontFace) : Checkable #

[View source]
def check(node : Ast::CssKeyframes) : Checkable #

[View source]
def check(node : Ast::CssNestedAt) : Checkable #

[View source]
def check(node : Ast::CssSelector) : Checkable #

[View source]
def check(node : Ast::Dbg) : Checkable #

[View source]
def check(node : Ast::Decode) : Checkable #

[View source]
def check(node : Ast::Defer) : Checkable #

[View source]
def check(node : Ast::Emit) : Checkable #

[View source]
def check(node : Ast::Encode) : Checkable #

[View source]
def check(node : Ast::Env) : Checkable #

[View source]
def check(node : Ast::Field, should_create_record : Bool = false) : Checkable #

[View source]
def check(node : Ast::FieldAccess) : Checkable #

[View source]
def check(node : Ast::For) : Checkable #

[View source]
def check(node : Ast::Function) #

[View source]
def check(node : Ast::Get) : Checkable #

[View source]
def check(node : Ast::HereDocument) : Checkable #

[View source]
def check(node : Ast::HtmlComponent) : Checkable #

[View source]
def check(node : Ast::HtmlElement) : Checkable #

[View source]
def check(node : Ast::HtmlFragment) : Checkable #

[View source]
def check(node : Ast::HtmlStyle) : Checkable #

[View source]
def check(node : Ast::If) : Checkable #

[View source]
def check(node : Ast::InlineFunction) #

[View source]
def check(node : Ast::Interpolation) : Checkable #

[View source]
def check(node : Ast::Js) : Checkable #

[View source]
def check(node : Ast::LocaleKey) : Checkable #

[View source]
def check(node : Ast::Map) : Checkable #

[View source]
def check(node : Ast::Module) : Checkable #

[View source]
def check(node : Ast::NegatedExpression) : Checkable #

[View source]
def check(node : Ast::NextCall) : Checkable #

[View source]
def check(node : Ast::NumberLiteral) : Checkable #

[View source]
def check(node : Ast::Operation) : Checkable #

[View source]

[View source]
def check(node : Ast::Pipe) : Checkable #

[View source]
def check(node : Ast::Property) : Checkable #

[View source]
def check(node : Ast::Provider) : Checkable #

[View source]
def check(node : Ast::Record, should_create_record : Bool = false) : Checkable #

[View source]
def check(node : Ast::RecordUpdate) : Checkable #

[View source]
def check(node : Ast::RegexpLiteral) : Checkable #

[View source]
def check(node : Ast::ReturnCall) : Checkable #

[View source]
def check(node : Ast::Route) : Checkable #

[View source]
def check(node : Ast::Routes) : Checkable #

[View source]
def check(node : Ast::Signal) : Checkable #

[View source]
def check(node : Ast::State) : Checkable #

[View source]
def check(node : Ast::StateSetter) : Checkable #

[View source]
def check(node : Ast::Statement) : Checkable #

[View source]
def check(node : Ast::Store) : Checkable #

[View source]
def check(node : Ast::StringLiteral) : Checkable #

[View source]
def check(node : Ast::Style) : Checkable #

[View source]
def check(node : Ast::Suite) #

[View source]
def check(node : Ast::Test) #

[View source]
def check(node : Ast) : Checkable #

[View source]
def check(node : Ast::TupleLiteral) : Checkable #

[View source]
def check(node : Ast::Type) : Checkable #

[View source]
def check(node : Ast::TypeDefinition) : Checkable #

[View source]
def check(node : Ast::TypeDefinitionField) : Checkable #

[View source]
def check(node : Ast::TypeVariable) : Checkable #

[View source]
def check(node : Ast::TypeVariant) : Checkable #

[View source]
def check(node : Ast::UnaryMinus) : Checkable #

[View source]
def check(node : Ast::Use) : Checkable #

[View source]
def check(node : Ast::Variable) : Checkable #

[View source]
def check(node : Ast::Directives::Asset) : Checkable #

[View source]
def check(node : Ast::Directives::Format) : Checkable #

[View source]
def check(node : Ast::Directives::Highlight) : Checkable #

[View source]

[View source]
def check(node : Ast::Directives::Inline) : Checkable #

[View source]
def check(node : Ast::Directives::Svg) : Checkable #

[View source]
def check(node : Checkable) : Checkable #

[View source]
def check(nodes : Array(Ast::Node)) : Array(Checkable) #

[View source]
def check(node : Ast::Node) : Checkable #

[View source]
def check : Artifacts #

[View source]
def check!(node) #

[View source]
def check_all(node : Ast::Component) : Checkable #

Check all nodes that were not checked before


[View source]
def check_all(node : Ast::Module) : Checkable #

[View source]
def check_all(nodes : Array(Ast::Node)) : Array(Checkable) #

[View source]
def check_arguments(arguments : Array(Ast::Argument)) #

[View source]
def check_call(node, function_type) : Checkable #

[View source]
def check_decode(type : Checkable) #

[View source]
def check_everything? : Bool #

[View source]
def check_exhaustiveness(target : Checkable, patterns : Array(Ast::Node | Nil)) #

[View source]
def check_function(node : Ast::Function | Ast::InlineFunction) : Checkable #

[View source]
def check_global_names(name : String, node : Ast::Node) : Nil #

[View source]
def check_html(nodes : Array(Ast::Node)) : Checkable #

[View source]
def check_locale(node : Ast::Locale) #

[View source]
def check_locale_record(*, language : String, node : Ast::Field, prefix : String | Nil) #

[View source]
def check_names(nodes : Array(Ast::Function | Ast::Get | Ast::Property | Ast::State | Ast::Signal), error : String, resolved = {} of String => Ast::Node) : Nil #

[View source]
def checked(*args, **options) #

[View source]
def checked(*args, **options, &) #

[View source]
def checking=(checking : Bool) #

[View source]
def checking? : Bool #

[View source]
def component_records(*args, **options) #

[View source]
def component_records(*args, **options, &) #

[View source]
def components_touched(*args, **options) #

[View source]
def components_touched(*args, **options, &) #

[View source]
def create_record(fields) #

[View source]
def destructure(node : Nil, condition : Checkable, variables : Array(VariableScope) = [] of VariableScope) #

[View source]
def destructure(node : Ast::Discard, condition : Checkable, variables : Array(VariableScope) = [] of VariableScope) #

[View source]
def destructure(node : Ast::Variable, condition : Checkable, variables : Array(VariableScope) = [] of VariableScope) #

This is for the let statement when it's a single assignment


[View source]
def destructure(node : Ast::ArrayDestructuring, condition : Checkable, variables : Array(VariableScope) = [] of VariableScope) #

[View source]
def destructure(node : Ast::TupleDestructuring, condition : Checkable, variables : Array(VariableScope) = [] of VariableScope) #

[View source]
def destructure(node : Ast::TypeDestructuring, condition : Checkable, variables : Array(VariableScope) = [] of VariableScope) #

[View source]
def destructure(node : Ast::Node, condition : Checkable, variables : Array(VariableScope) = [] of VariableScope) #

[View source]
def destructuring_type_mismatch(expected : Checkable, got : Checkable, node : Ast::Node) #

[View source]
def format(*args, **options) #

[View source]
def format(*args, **options, &) #

[View source]
def formatter : Mint::Formatter #

[View source]
def global_name_conflict(other : Ast::Node, node : Ast::Node, what : String, name : String) #

[View source]
def here_doc_interpolation_type_mismatch(*, node : Ast::Node, type : Checkable, got : Checkable) #

TODO Show all possible types that can be...


[View source]
def invalid_self_reference(referee : Ast::Node, node : Ast::Node) #

[View source]
def locales(*args, **options) #

[View source]
def locales(*args, **options, &) #

[View source]
def lookup(node : Ast::Variable) #

[View source]
def lookup_with_level(node : Ast::Variable) #

[View source]
def lookups(*args, **options) #

[View source]
def lookups(*args, **options, &) #

[View source]
def operation_bool_type_mismatch(value : TypeChecker::Checkable, operator : String, node : Ast::Node, side : String) #

[View source]
def operation_numeric_type_mismatch(value : TypeChecker::Checkable, operator : String, node : Ast::Node, side : String) #

[View source]
def operation_plus_type_mismatch(value : TypeChecker::Checkable, node : Ast::Node, side : String) #

[View source]
def operation_type_mismatch(right : TypeChecker::Checkable, left : TypeChecker::Checkable, node : Ast::Node) #

[View source]
def ordinal(number) #

[View source]
def print_stack #

[View source]
def record_field_lookup(*args, **options) #

[View source]
def record_field_lookup(*args, **options, &) #

[View source]

[View source]
def references(*args, **options) #

[View source]
def references(*args, **options, &) #

[View source]
def resolve(nodes : Array(Ast::Node)) : Array(Checkable) #

[View source]
def resolve(node : Ast::Node | Checkable, *args) : Checkable #

[View source]
def resolve(nodes : Array(Ast::Node), *args) : Array(Checkable) #

[View source]
def resolve_order(*args, **options) #

[View source]
def resolve_order(*args, **options, &) #

[View source]
def resolve_record_definition(name) #

[View source]
def resolve_records #

[View source]
def resolve_type(node : Record | Variable) #

[View source]
def resolve_type(node : Type) #

[View source]
def scope(*args, **options) #

[View source]
def scope(*args, **options, &) #

[View source]
def static_type_signature(node) : Checkable #

This method computes the static type signature of an entity.


[View source]
def to_function_type(node : Ast::TypeVariant, parent : Ast::TypeDefinition) #

[View source]

[View source]

[View source]

[View source]
def to_pattern(node : Ast::Spread) : ExhaustivenessChecker::Pattern #

[View source]

[View source]
def to_pattern(node : Ast::Discard) : ExhaustivenessChecker::Pattern #

[View source]
def to_pattern(node : Ast::Node) : ExhaustivenessChecker::Pattern #

[View source]
def to_pattern(node : Nil) : ExhaustivenessChecker::Pattern #

[View source]
def to_pattern_type(node : Ast::Node) : ExhaustivenessChecker::Checkable #

[View source]
def to_pattern_type(type : Checkable) : ExhaustivenessChecker::Checkable #

[View source]
def track_references(node) #

[View source]
def trackable?(node : Ast::Node) #

[View source]
def unwind_access(node : Ast::Access, stack = [] of Ast::Variable) : Array(Ast::Variable) #

[View source]
def variables(*args, **options) #

[View source]
def variables(*args, **options, &) #

[View source]
def with_restricted_top_level_entity(referee : Mint::Ast::Node | Nil, &) #

[View source]