module Savi::Compiler::TInfer

Overview

This pass determines for each type/function, for all possible reifications, for each expression within it, the Span of possible types for that expression in each of those possible reifications. Information from upstream and sometimes downstream of each expression is used to infer types where needed.

A MetaType represents the type of an expression, which may refer to one or more type definitions and capabilities in various combinations (such as unions, intersections, etc), while a Span represents the set of those MetaTypes that are possible in the different possible reifications. A function or type with no type parameters or generic capabilities present will only have one possible reification, so all expressions therein will have a Span with just one Terminal MetaType in it.

After this pass, the types of expressions will be known, but not fully type-checked, as that work of type system verification happens in the later TypeCheck pass, which is decoupled from this pass because in theory type-checking is not necessary to compile a correct program, so it is a separate concern from that of marking the types of expressions in the program.

This pass does not mutate the Program topology. This pass does not mutate the AST. This pass may raise a compilation error. This pass keeps state at the per-type and per-function level. This pass produces output state at the per-type and per-function level.

Defined in:

savi/compiler/t_infer.cr
savi/compiler/t_infer/conduit.cr
savi/compiler/t_infer/info.cr
savi/compiler/t_infer/reified.cr
savi/compiler/t_infer/span.cr

Class Method Summary

Class Method Detail

def self.is_type_expr_cap?(node : AST::Node) : Bool #

[View source]