浏览代码

[js] apply var escaping rules to function arguments as well (fixes #6449)

Dan Korostelev 8 年之前
父节点
当前提交
dc2e5d8b8a
共有 2 个文件被更改,包括 19 次插入1 次删除
  1. 5 1
      src/generators/genjs.ml
  2. 14 0
      tests/unit/src/unit/issues/Issue6449.hx

+ 5 - 1
src/generators/genjs.ml

@@ -551,7 +551,11 @@ and gen_expr ctx e =
 		let old = ctx.in_value, ctx.in_loop in
 		ctx.in_value <- None;
 		ctx.in_loop <- false;
-		print ctx "function(%s) " (String.concat "," (List.map ident (List.map arg_name f.tf_args)));
+		let args = List.map (fun (v,_) ->
+			check_var_declaration v;
+			ident v.v_name
+		) f.tf_args in
+		print ctx "function(%s) " (String.concat "," args);
 		gen_expr ctx (fun_block ctx f e.epos);
 		ctx.in_value <- fst old;
 		ctx.in_loop <- snd old;

+ 14 - 0
tests/unit/src/unit/issues/Issue6449.hx

@@ -0,0 +1,14 @@
+package unit.issues;
+
+class Issue6449 extends unit.Test {
+	#if js
+	function test() {
+		t(doTest(Math.NaN));
+		f(doTest(1.5));
+	}
+
+	static function doTest(isNaN:Float):Bool {
+		return untyped __js__("isNaN")(isNaN);
+	}
+	#end
+}