Jelajahi Sumber

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

closes #6943
Simon Krajewski 7 tahun lalu
induk
melakukan
4a4e31a645
2 mengubah file dengan 16 tambahan dan 2 penghapusan
  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 =
 let type_function_arg ctx t e opt p =
 	if opt then
 	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
 		ctx.t.tnull t, e
 	else
 	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
 		t, e
 
 
 let type_var_field ctx t e stat do_display p =
 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)));
+	}
+}