Browse Source

[parser] allow parsing `<>` when in display mode

closes #7111
Simon Krajewski 7 years ago
parent
commit
075a40e1e1
2 changed files with 15 additions and 1 deletions
  1. 1 1
      src/syntax/grammar.mly
  2. 14 0
      tests/display/src/cases/Issue7111.hx

+ 1 - 1
src/syntax/grammar.mly

@@ -590,7 +590,7 @@ and parse_type_path_or_const = parser
 	| [< '(Kwd True,p) >] -> TPExpr (EConst (Ident "true"),p)
 	| [< '(Kwd False,p) >] -> TPExpr (EConst (Ident "false"),p)
 	| [< e = expr >] -> TPExpr e
-	| [< >] -> serror()
+	| [< >] -> if !in_display then raise Stream.Failure else serror()
 
 and parse_complex_type_next (t : type_hint) s =
 	let make_fun t2 p2 = match t2 with

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

@@ -0,0 +1,14 @@
+package cases;
+
+class Issue7111 extends DisplayTestCase {
+	/**
+	class {-1-}Main{-2-}<T> {
+		public static function main() {
+			var a:Ma{-3-}in<>
+		}
+	}
+	**/
+	function test() {
+		eq(range(1, 2), position(pos(3)));
+	}
+}