Browse Source

disallow inline @:op functions without expressions

Simon Krajewski 11 years ago
parent
commit
8cba1d414d
1 changed files with 8 additions and 2 deletions
  1. 8 2
      typeload.ml

+ 8 - 2
typeload.ml

@@ -1768,13 +1768,19 @@ let init_class ctx c p context_init herits fields =
 							if not (left_eq || right_eq) then error ("The left or right argument type must be " ^ (s_type (print_context()) targ)) f.cff_pos;
 							if right_eq && Meta.has Meta.Commutative f.cff_meta then error ("@:commutative is only allowed if the right argument is not " ^ (s_type (print_context()) targ)) f.cff_pos;
 							a.a_ops <- (op,cf) :: a.a_ops;
-							if fd.f_expr = None then do_bind := false;
+							if fd.f_expr = None then begin
+								if inline then error ("Inline operator functions must have an expression") f.cff_pos;
+								do_bind := false
+							end;
 						| (Meta.Op,[EUnop(op,flag,_),_],_) :: _ ->
 							if is_macro then error "Macro operator functions are not supported" p;
 							let targ = if Meta.has Meta.Impl f.cff_meta then tthis else ta in
 							(try type_eq EqStrict t (tfun [targ] (mk_mono())) with Unify_error l -> raise (Error ((Unify l),f.cff_pos)));
 							a.a_unops <- (op,flag,cf) :: a.a_unops;
-							if fd.f_expr = None then do_bind := false;
+							if fd.f_expr = None then begin
+								if inline then error ("Inline operator functions must have an expression") f.cff_pos;
+								do_bind := false
+							end;
 						| _ :: ml ->
 							loop ml
 						| [] ->