Explorar el Código

allow body-less @:op methods to return the abstract type if the operation type is equal to its underlying type (closes #2409)

Simon Krajewski hace 12 años
padre
commit
af2e128b1b
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      typer.ml

+ 5 - 1
typer.ml

@@ -1836,7 +1836,11 @@ let rec type_binop ctx op e1 e2 is_assign_op p =
 			begin try
 				unify_raise ctx e.etype r p
 			with Error (Unify _,_) ->
-				error ("The result of this operation (" ^ (s_type (print_context()) e.etype) ^ ") is not compatible with declared return type " ^ (s_type (print_context()) r)) p;
+				match follow r with
+					| TAbstract(a,tl) when type_iseq (Codegen.Abstract.get_underlying_type a tl) e.etype ->
+						()
+					| _ ->
+						error ("The result of this operation (" ^ (s_type (print_context()) e.etype) ^ ") is not compatible with declared return type " ^ (s_type (print_context()) r)) p;
 			end;
 			{e with etype = r}
 		end