Browse Source

bugfix : use "undefined" instead of "null" for flash8/js skipped called parameters (allow usage of default value)

Nicolas Cannasse 14 years ago
parent
commit
e97c79b96f
1 changed files with 7 additions and 2 deletions
  1. 7 2
      typer.ml

+ 7 - 2
typer.ml

@@ -128,9 +128,14 @@ let unify_call_params ctx name el args p inline =
 	let arg_error ul name opt p =
 		raise (Error (Stack (Unify ul,Custom ("For " ^ (if opt then "optional " else "") ^ "function argument '" ^ name ^ "'")), p))
 	in
+	let enull = (match ctx.com.platform with
+		| Js -> TLocal "undefined"
+		| Flash -> TLocal "__undefined__"
+		| _ -> TConst TNull
+	) in
 	let rec no_opt = function
 		| [] -> []
-		| ({ eexpr = TConst TNull },true) :: l -> no_opt l
+		| (e,true) :: l when e.eexpr == enull -> no_opt l
 		| l -> List.map fst l
 	in
 	let rec default_value t =
@@ -153,7 +158,7 @@ let unify_call_params ctx name el args p inline =
 			let e = type_expr ctx infos true in
 			(e, true)
 		else
-			(null t p, true)
+			(mk enull t p, true)
 	in
 	let rec loop acc l l2 skip =
 		match l , l2 with