Browse Source

give meaningful error when @:op functions cannot be accessed

Simon Krajewski 12 years ago
parent
commit
a5fbc35f24
1 changed files with 2 additions and 1 deletions
  1. 2 1
      typer.ml

+ 2 - 1
typer.ml

@@ -1575,7 +1575,8 @@ let rec type_binop ctx op e1 e2 is_assign_op p =
 			| [] -> raise Not_found
 			| (o,cf) :: ops when is_assign_op && o = OpAssignOp(op) || o == op ->
 				(match follow (monomorphs cf.cf_params cf.cf_type) with
-				| TFun([(_,_,t1);(_,_,t2)],r) when (left || Meta.has Meta.Commutative cf.cf_meta) && type_iseq t t2 && can_access ctx c cf true ->
+				| TFun([(_,_,t1);(_,_,t2)],r) when (left || Meta.has Meta.Commutative cf.cf_meta) && type_iseq t t2 ->
+					if not (can_access ctx c cf true) then display_error ctx ("Cannot access operator function " ^ (s_type_path a.a_path) ^ "." ^ cf.cf_name) p;
 					cf,r,o = OpAssignOp(op)
 				| _ -> loop ops)
 			| _ :: ops ->