Przeglądaj źródła

[parser] don't lose questionable identifier positions

closes #9101
Simon Krajewski 5 lat temu
rodzic
commit
9fe1fb5260
2 zmienionych plików z 15 dodań i 1 usunięć
  1. 1 1
      src/syntax/grammar.mly
  2. 14 0
      tests/display/src/cases/Issue9101.hx

+ 1 - 1
src/syntax/grammar.mly

@@ -727,7 +727,7 @@ and parse_type_anonymous s =
 	match s with parser
 	| [< name, p1 = ident; t = parse_type_hint; s >] ->
 		let opt,p1 = match p0 with
-			| Some p -> true,p
+			| Some p -> true,punion p p1
 			| None -> false,p1
 		in
 		let p2 = pos (last_token s) in

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

@@ -0,0 +1,14 @@
+package cases;
+
+class Issue9101 extends DisplayTestCase {
+	/**
+		typedef T = {
+		?{-1-}t{-2-}e{-3-}st:Int
+		}
+	**/
+	function testCatch_noTypeHint() {
+		eq("Null<Int>", type(pos(1)));
+		eq("Null<Int>", type(pos(2)));
+		eq("Null<Int>", type(pos(3)));
+	}
+}