Browse Source

[display] don't fall back to outer type display if inner one fails

see #7878
Simon Krajewski 6 years ago
parent
commit
7083afa2e9
3 changed files with 21 additions and 1 deletions
  1. 6 0
      src/context/display/display.ml
  2. 1 1
      src/typing/typeload.ml
  3. 14 0
      tests/display/src/cases/Issue7878.hx

+ 6 - 0
src/context/display/display.ml

@@ -133,6 +133,12 @@ module ExprPreprocessing = struct
 				raise Exit
 				raise Exit
 			| EConst(Regexp _) when is_annotated (pos e) && is_completion ->
 			| EConst(Regexp _) when is_annotated (pos e) && is_completion ->
 				raise Exit
 				raise Exit
+			| EVars vl when is_annotated (pos e) ->
+				(* We only want to mark EVars if we're on a var name. *)
+				if List.exists (fun ((_,pn),_,_,_) -> is_annotated pn) vl then
+					annotate_marked e
+				else
+					raise Exit
 			| _ ->
 			| _ ->
 				if is_annotated (pos e) then
 				if is_annotated (pos e) then
 					annotate_marked e
 					annotate_marked e

+ 1 - 1
src/typing/typeload.ml

@@ -543,7 +543,7 @@ and load_complex_type ctx allow_display (t,pn) =
 		if Diagnostics.is_diagnostics_run p then begin
 		if Diagnostics.is_diagnostics_run p then begin
 			delay ctx PForce (fun () -> DisplayToplevel.handle_unresolved_identifier ctx name p true);
 			delay ctx PForce (fun () -> DisplayToplevel.handle_unresolved_identifier ctx name p true);
 			t_dynamic
 			t_dynamic
-		end else if ctx.com.display.dms_display then
+		end else if ctx.com.display.dms_display && not (DisplayPosition.encloses_display_position pn) then
 			t_dynamic
 			t_dynamic
 		else
 		else
 			raise exc
 			raise exc

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

@@ -0,0 +1,14 @@
+package cases;
+
+class Issue7878 extends DisplayTestCase {
+	/**
+	class Main {
+	public static function main() {
+		var f:Array<SomethingUnk{-1-}nown>;
+	}
+}
+	**/
+	function test() {
+		// TODO: need assertError or something
+	}
+}