Browse Source

check for toString when using `trace(abstract type)` on optimized Js

Simon Krajewski 11 years ago
parent
commit
d7f704e380
1 changed files with 6 additions and 0 deletions
  1. 6 0
      typer.ml

+ 6 - 0
typer.ml

@@ -3193,6 +3193,12 @@ and type_call ctx e el (with_type:with_type) p =
 		if platform ctx.com Js && el = [] && has_dce ctx.com then
 			let e = type_expr ctx e Value in
 			let infos = type_expr ctx infos Value in
+			let e = match follow e.etype with
+				| TAbstract({a_impl = Some c},_) when PMap.mem "toString" c.cl_statics ->
+					call_to_string ctx c e
+				| _ ->
+					e
+			in
 			mk (TCall (mk (TLocal (alloc_var "`trace" t_dynamic)) t_dynamic p,[e;infos])) ctx.t.tvoid p
 		else
 			let me = Meta.ToString,[],pos e in