Browse Source

group constraint failure into a single error message (for compilation server)

Nicolas Cannasse 13 years ago
parent
commit
94ff93394f
3 changed files with 4 additions and 2 deletions
  1. 1 0
      type.ml
  2. 2 0
      typecore.ml
  3. 1 2
      typer.ml

+ 1 - 0
type.ml

@@ -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
 

+ 2 - 0
typecore.ml

@@ -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

+ 1 - 2
typer.ml

@@ -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
 				);
 			| _ -> ()