Skip to content

Commit

Permalink
group constraint failure into a single error message (for compilation…
Browse files Browse the repository at this point in the history
… server)
  • Loading branch information
ncannasse committed Jun 21, 2012
1 parent f533ae2 commit 94ff933
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ type unify_error =
| Not_matching_optional of string
| Cant_force_optional
| Invariant_parameter of t * t
| Constraint_failure of string

exception Unify_error of unify_error list

Expand Down
2 changes: 2 additions & 0 deletions typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ let unify_error_msg ctx = function
"Optional parameters can't be forced"
| Invariant_parameter _ ->
"Type parameters are invariant"
| Constraint_failure name ->
"Constraint check failure for " ^ name

let rec error_msg = function
| Module_not_found m -> "Class not found : " ^ Ast.s_type_path m
Expand Down
3 changes: 1 addition & 2 deletions typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ let field_type ctx c pl f p =
try
Type.unify m ct
with Unify_error l ->
display_error ctx ("Constraint check failure for parameter " ^ f.cf_name ^ "." ^ name) p;
display_error ctx (error_msg (Unify l)) p;
display_error ctx (error_msg (Unify (Constraint_failure (f.cf_name ^ "." ^ name) :: l))) p;
) constr
);
| _ -> ()
Expand Down

0 comments on commit 94ff933

Please sign in to comment.