Ver Fonte

(Flash/Js) comment out Std.string optimization (closes #2716)

Simon Krajewski há 11 anos atrás
pai
commit
a2fcda35e0
2 ficheiros alterados com 11 adições e 2 exclusões
  1. 2 2
      optimizer.ml
  2. 9 0
      tests/unit/issues/Issue2716.hx

+ 2 - 2
optimizer.ml

@@ -69,7 +69,7 @@ let api_inline ctx c field params p =
 			Some { eexpr = TConst (TString (if b then "true" else "false")); epos = p; etype = ctx.t.tstring }
 		| _ ->
 			None)
-	| ([],"Std"),"string",[v] when ctx.com.platform = Js || ctx.com.platform = Flash ->
+(* 	| ([],"Std"),"string",[v] when ctx.com.platform = Js || ctx.com.platform = Flash ->
 		let pos = v.epos in
 		let stringt = ctx.com.basic.tstring in
 		let stringv = mk (TBinop (Ast.OpAdd, mk (TConst (TString "")) stringt pos, v)) stringt pos in
@@ -85,7 +85,7 @@ let api_inline ctx c field params p =
 		| TAbstract ({ a_path = [],"Bool" }, []) ->
 			Some stringv
 		| _ ->
-			None)
+			None) *)
 	| ([],"Std"),"is",[o;t] | (["js"],"Boot"),"__instanceof",[o;t] when ctx.com.platform = Js ->
 		let mk_local ctx n t pos = mk (TLocal (try PMap.find n ctx.locals with _ -> add_local ctx n t)) t pos in
 

+ 9 - 0
tests/unit/issues/Issue2716.hx

@@ -0,0 +1,9 @@
+package unit.issues;
+import unit.Test;
+
+class Issue2716 extends Test {
+	function test() {
+		eq("null", Std.string(['foo', null][Std.random(1)+1]));
+		eq("null", Std.string(['foo'][Std.random(1)+1]));
+	}
+}