浏览代码

fix positions of classes in resume case (closes #5171)

Simon Krajewski 9 年之前
父节点
当前提交
99b9207f47

+ 1 - 1
src/syntax/parser.ml

@@ -742,7 +742,7 @@ and parse_class_fields tdecl p1 s =
 	let l = parse_class_field_resume tdecl s in
 	let p2 = (match s with parser
 		| [< '(BrClose,p2) >] -> p2
-		| [< >] -> if do_resume() then p1 else serror()
+		| [< >] -> if do_resume() then pos (last_token s) else serror()
 	) in
 	l, p2
 

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

@@ -0,0 +1,14 @@
+package cases;
+
+class Issue5171 extends DisplayTestCase {
+	/**
+	{-2-}class Main {
+		static function main() {
+			Ma{-1-}in;
+		}
+	}{-3-}
+	**/
+	function test() {
+		eq(range(2, 3), position(pos(1)));
+	}
+}

+ 2 - 2
tests/display/src/cases/Super.hx

@@ -18,9 +18,9 @@ class Super extends DisplayTestCase {
 	}
 
 	/**
-	{-1-}class{-2-} Base<T> {
+	{-1-}class Base<T> {
 		public {-4-}function test() { }{-5-}
-	}
+	}{-2-}
 	class Main extends Base<String> {
 		override function test() {
 			su{-3-}per.te{-6-}st();

+ 1 - 1
tests/misc/projects/Issue2996/compile1.hxml.stderr

@@ -1,3 +1,3 @@
 <list>
-<pos>$$normPath(::cwd::/A.hx):1: characters 0-8</pos>
+<pos>$$normPath(::cwd::/A.hx):1: characters 0-21</pos>
 </list>

+ 1 - 1
tests/misc/projects/Issue2996/compile2.hxml.stderr

@@ -1,3 +1,3 @@
 <list>
-<pos>$$normPath(::cwd::/pack/B.hx):3: characters 0-5</pos>
+<pos>$$normPath(::cwd::/pack/B.hx):3: characters 0-10</pos>
 </list>

+ 1 - 2
tests/misc/projects/Issue5134/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Main.hx:21: characters 8-9 : Cannot access a in static function
-Main.hx:12: characters 0-5 : Defined in this class
+Main.hx:21: characters 8-9 : Cannot access a in static function