Pārlūkot izejas kodu

[parser] remove strange Error catching

closes #8687
Simon Krajewski 1 gadu atpakaļ
vecāks
revīzija
3a9445219a

+ 0 - 2
src/syntax/grammar.mly

@@ -1138,8 +1138,6 @@ and block_with_pos' acc f p s =
 		| Stream.Error msg when !in_display_file ->
 			handle_stream_error msg s;
 			(block_with_pos acc (next_pos s) s)
-		| Error (e,p) when !in_display_file ->
-			block_with_pos acc p s
 
 and block_with_pos acc p s =
 	block_with_pos' acc parse_block_elt p s

+ 2 - 0
tests/display/src/Diagnostic.hx → std/haxe/display/Diagnostic.hx

@@ -1,4 +1,6 @@
 // from vshaxe
+package haxe.display;
+
 import haxe.display.Position.Location;
 import haxe.display.Position.Range;
 import haxe.display.JsonModuleTypes;

+ 1 - 1
tests/display/src/import.hx

@@ -1 +1 @@
-import Diagnostic;
+import haxe.display.Diagnostic;

+ 6 - 0
tests/server/src/TestCase.hx

@@ -6,6 +6,7 @@ import haxeserver.HaxeServerRequestResult;
 import haxe.display.JsonModuleTypes;
 import haxe.display.Display;
 import haxe.display.Protocol;
+import haxe.display.Diagnostic;
 import haxe.Json;
 import haxeserver.process.HaxeServerProcessNode;
 import haxeserver.HaxeServerAsync;
@@ -191,6 +192,11 @@ class TestCase implements ITest {
 		return haxe.Json.parse(lastResult.stderr).result;
 	}
 
+	function parseDiagnostics():Array<Diagnostic<Any>> {
+		var result = haxe.Json.parse(lastResult.stderr)[0];
+		return if (result == null) [] else result.diagnostics;
+	}
+
 	function parseGotoDefinitionLocations():Array<Location> {
 		switch parseGotoTypeDefinition().result {
 			case null:

+ 12 - 0
tests/server/src/cases/issues/Issue8687.hx

@@ -0,0 +1,12 @@
+package cases.issues;
+
+class Issue8687 extends TestCase {
+	function test(_) {
+		vfs.putContent("Main.hx", getTemplate("issues/Issue8687/Main.hx"));
+		var args = ["-main", "Main", "--interp"];
+		runHaxe(args.concat(["--display", "Main.hx@0@diagnostics"]));
+
+		var diag = parseDiagnostics();
+		Assert.equals("Invalid version string \"foo\". Should follow SemVer.", diag[0].args);
+	}
+}

+ 7 - 0
tests/server/test/templates/issues/Issue8687/Main.hx

@@ -0,0 +1,7 @@
+class Main {
+	static function main() {
+		trace("test");
+		#if ("foo" == version("4.0.0"))
+		#end
+	}
+}