Melange_compiler_libs.Errortrace
let print_pos: Stdlib.Format.formatter => position => unit;
let trivial_expansion: Types.type_expr => expanded_type;
trivial_expansion ty
creates an expanded_type
whose expansion is also ty
. Usually, you want Ctype.expand_type
instead, since the expansion carries useful information; however, in certain circumstances, the error is about the expansion of the type, meaning that actually performing the expansion produces more confusing or inaccurate output.
map_diff f {expected;got}
is {expected=f expected; got=f got}
type escape_kind('a) =
| Constructor(Path.t)
| Univ(Types.type_expr)
| Self
| Module_type(Path.t)
| Equation('a)
| Constraint
;
Scope escape related errors
type variant('variety) =
| Incompatible_types_for(string) : variant(_)
| No_intersection : variant(unification)
| Fixed_row(position, fixed_row_case, Types.fixed_explanation) : variant(
unification)
| Presence_not_guaranteed_for(position, string) : variant(comparison)
| Openness(position) : variant(comparison)
;
type elt('a, 'variety) =
| Diff(diff('a)) : elt('a, _)
| Variant(variant('variety)) : elt('a, 'variety)
| Obj(obj('variety)) : elt('a, 'variety)
| Escape(escape('a)) : elt('a, _)
| Incompatible_fields: {
name: string,
diff: diff(Types.type_expr),
} : elt('a, _)
| Rec_occur(Types.type_expr, Types.type_expr) : elt('a, _)
;
type t('a, 'variety) = list(elt('a, 'variety));
type trace('variety) = t(Types.type_expr, 'variety);
type error('variety) = t(expanded_type, 'variety);
let incompatible_fields:
name:string =>
got:Types.type_expr =>
expected:Types.type_expr =>
elt(Types.type_expr, _);
The traces ('variety t
) are the core error types. However, we bundle them up into three "top-level" error types, which are used elsewhere: unification_error
, equality_error
, and moregen_error
. In the case of equality_error
, this has to bundle in extra information; in general, it distinguishes the three types of errors and allows us to distinguish traces that are being built (or processed) from those that are complete and have become the final error. These error types have the invariants that their traces are nonempty; we ensure that through three smart constructors with matching names.
type equality_error = pri {
trace: error(comparison),
subst: list((Types.type_expr, Types.type_expr)),
};
let unification_error: trace:error(unification) => unification_error;
let equality_error:
trace:error(comparison) =>
subst:list((Types.type_expr, Types.type_expr)) =>
equality_error;
let moregen_error: trace:error(comparison) => moregen_error;
Wraps up the two different kinds of comparison
errors in one type
let swap_unification_error: unification_error => unification_error;
Lift swap_trace
to unification_error
module Subtype: { ... };