瀏覽代碼

[typer] set generated `null` default values to `null_pos`

closes #6943
Simon Krajewski 7 年之前
父節點
當前提交
4a4e31a645
共有 2 個文件被更改,包括 16 次插入2 次删除
  1. 2 2
      src/typing/typeloadFunction.ml
  2. 14 0
      tests/display/src/cases/Issue6943.hx

+ 2 - 2
src/typing/typeloadFunction.ml

@@ -29,10 +29,10 @@ open Error
 
 let type_function_arg ctx t e opt p =
 	if opt then
-		let e = (match e with None -> Some (EConst (Ident "null"),p) | _ -> e) in
+		let e = (match e with None -> Some (EConst (Ident "null"),null_pos) | _ -> e) in
 		ctx.t.tnull t, e
 	else
-		let t = match e with Some (EConst (Ident "null"),p) -> ctx.t.tnull t | _ -> t in
+		let t = match e with Some (EConst (Ident "null"),null_pos) -> ctx.t.tnull t | _ -> t in
 		t, e
 
 let type_var_field ctx t e stat do_display p =

+ 14 - 0
tests/display/src/cases/Issue6943.hx

@@ -0,0 +1,14 @@
+package cases;
+
+class Issue6943 extends DisplayTestCase {
+	/**
+class Main {
+    public static function main() {}
+
+    function foo(?{-1-}te{-2-}st{-3-}:Int) {}
+}
+	**/
+	function test() {
+		eq(range(1, 3), position(pos(2)));
+	}
+}