Explorar o código

[display] fix reference handling with nonexisting positions

Simon Krajewski %!s(int64=7) %!d(string=hai) anos
pai
achega
cc727f036c
Modificáronse 2 ficheiros con 3 adicións e 2 borrados
  1. 1 0
      src/compiler/displayOutput.ml
  2. 2 2
      src/context/display.ml

+ 1 - 0
src/compiler/displayOutput.ml

@@ -759,6 +759,7 @@ let process_global_display_mode com tctx = match com.display.dms_kind with
 			let c = compare p1.pfile p2.pfile in
 			let c = compare p1.pfile p2.pfile in
 			if c <> 0 then c else compare p1.pmin p2.pmin
 			if c <> 0 then c else compare p1.pmin p2.pmin
 		) usages in
 		) usages in
+		Display.reference_position := null_pos;
 		raise (DisplayPosition usages)
 		raise (DisplayPosition usages)
 	| DMDiagnostics global ->
 	| DMDiagnostics global ->
 		Diagnostics.prepare com global;
 		Diagnostics.prepare com global;

+ 2 - 2
src/context/display.ml

@@ -599,13 +599,13 @@ module Statistics = struct
 		let relations = Hashtbl.create 0 in
 		let relations = Hashtbl.create 0 in
 		let symbols = Hashtbl.create 0 in
 		let symbols = Hashtbl.create 0 in
 		let add_relation pos r =
 		let add_relation pos r =
-			try
+			if pos <> null_pos then try
 				Hashtbl.replace relations pos (r :: Hashtbl.find relations pos)
 				Hashtbl.replace relations pos (r :: Hashtbl.find relations pos)
 			with Not_found ->
 			with Not_found ->
 				Hashtbl.add relations pos [r]
 				Hashtbl.add relations pos [r]
 		in
 		in
 		let declare kind p =
 		let declare kind p =
-			begin
+			if p <> null_pos then begin
 				if not (Hashtbl.mem relations p) then Hashtbl.add relations p [];
 				if not (Hashtbl.mem relations p) then Hashtbl.add relations p [];
 				Hashtbl.replace symbols p kind;
 				Hashtbl.replace symbols p kind;
 			end
 			end