Skip to content

Latest commit

 

History

History
13 lines (13 loc) · 2.73 KB

File metadata and controls

13 lines (13 loc) · 2.73 KB

Constraint Kinds

Constraint Type Description Example Code Generating the Constraint
Equality(T, U) Asserts that type T must be exactly the same as type U. The most fundamental constraint. let x = y;
NonVoidEquality(T, U) Asserts T must equal U, and additionally ensures the unified type is not void. let my_variable = some_expression;
FunctionSignature(Callee, Params, Return) Models a direct function call, asserting that Callee is a function type with Params and Return type. my_function(10);
MethodCall(Instance, Callee, Args, Return) Models a method call, linking the Instance type to the Callee signature and its Args/Return. my_vector.push(5);
Operation(Result, Trait, Lhs, Rhs) Models a trait-based operator, stating Result is the Output of Trait<Rhs> implemented for Lhs. let result = a + b;
InstanceMemberAccess(Result, Base, Member) Models accessing a field or method on an instance variable. Result is the type of the Member. let x = my_struct.field;
StaticMemberAccess(Result, Base, Member) Models accessing a static member, like an enum variant or associated function, on a Base type. let color = Color.Red;
FullyQualifiedAccess(Result, Ty, Tr, Member) Models a fully qualified path [Ty as Tr].Member, used to disambiguate or access associated items. let default_val = [Vec<int> as Default].default();
Cast(Source, Target) Asserts that a value of type Source can be legally cast to Target. let x = 5.0 as int;
ExpressionStatement(Inner, Result) Determines the type of a statement. Result is never if Inner diverges, otherwise void. some_function();