Browse Source

match documentation : function parameters are nullable if they are declared with '?'

Nicolas Cannasse 13 năm trước cách đây
mục cha
commit
87e429e872
2 tập tin đã thay đổi với 6 bổ sung5 xóa
  1. 1 0
      doc/CHANGES.txt
  2. 5 5
      typeload.ml

+ 1 - 0
doc/CHANGES.txt

@@ -16,6 +16,7 @@
 	flash : bugfix for @:bitmap with 24-bits PNG (flash decode wrong colors)
 	as3 : fixed EnumValue becomes Object
 	js : removed js.Lib.isIE/isOpera (not complete, use js.JQuery.browser instead)
+	all : function parameters are nullable if they are declared with '?'
 
 2012-04-14: 2.09
 	all : optimized const == const and const != const (with different const types)

+ 5 - 5
typeload.ml

@@ -37,11 +37,11 @@ let type_module_hook = ref (fun _ _ _ -> None)
 let return_partial_type = ref false
 
 let type_function_param ctx t e opt p =
-	match e with
-	| None ->
-		if opt then ctx.t.tnull t, Some (EConst (Ident "null"),p) else t, None
-	| Some e ->
-		t, Some e
+	if opt then
+		let e = (match e with None -> Some (EConst (Ident "null"),p) | _ -> e) in
+		ctx.t.tnull t, e
+	else
+		t, e
 
 let type_static_var ctx t e p =
 	ctx.curfun <- FStatic;