TypeEnv
Constructors
Instance methods
Emit a warning if one set of arguments may match multiple functions. This occurs if two functions have the same number of parameters and the type of each parameter is either a type variable or the same type
For now it just issues a warning, but in the future it may issue an error and disallow such ambiguities.
For each "Type is Trait" ("extend" clauses and traits put directly on a type), check to make sure the trait itself is valid and that the required methods actually exist.
evaluate all type nodes for the fields of structs and of enum variants also re-evaluate the type nodes of function parameters and return types
property implementations : ::Hash(Trait, Implements) = {} of Trait => Implements property trait_claims = [] of TraitClaim property ast_functions = {} of String => Array(Ast::Function) property external_functions = [] of Ast::ExternalFunction
property implementations : ::Hash(Trait, Implements) = {} of Trait => Implements property trait_claims = [] of TraitClaim property ast_functions = {} of String => Array(Ast::Function) property external_functions = [] of Ast::ExternalFunction
Before checking the trait claims, all missing methods must be implemented with their default implementation (if it exists). This must be done in a separate pass because a given trait implementation may rely on the default implementation of another trait defined later.
This method currently uses Signature#== to find signature. This means it
is quite specific in what counts a match.
property functions = {} of String => Array(Function)
A second pass over the list of AST declarations now adds the constraints to the type parameters by evaluating the trait nodes into Traits However, trait compliance is not yet validated at this point This pass also stores all "trait claims"; ie, wherever the developer has indicated a given type implements a given trait. These trait claims may be generic as well.
This pass takes the AST of each type declaration and inserts it into the global map of type definitions @type_defs Each TypeDef has a name, 0 or more type parameters, and fields (if struct) or variants (if enum) However, at this stage, only the names of the type parameters are stored (no constraints yet, and no fields or variants)
This method is an alternative to the above to be used in testing
Store the typedefs of strings and arrays in the node classes for their associated literals for convenient production of their types. This avoids the need to always pass the TypeEnv when hir nodes tell their type to the type checker.
Starting with fn main, instantiate and check all functions used in the program