Sfoglia il codice sorgente

[display] fix range of pattern variables

see #7282
Simon Krajewski 1 anno fa
parent
commit
160a49095d

+ 6 - 5
src/context/display/diagnostics.ml

@@ -16,13 +16,14 @@ let find_unused_variables com e =
 	let vars = Hashtbl.create 0 in
 	let pmin_map = Hashtbl.create 0 in
 	let rec loop e = match e.eexpr with
-		| TVar({v_kind = VUser _} as v,eo) when v.v_name <> "_" && not (has_var_flag v VUsedByTyper) ->
+		| TVar({v_kind = VUser origin} as v,eo) when v.v_name <> "_" && not (has_var_flag v VUsedByTyper) ->
 			Hashtbl.add pmin_map e.epos.pmin v;
 			let p = match eo with
-				| None -> e.epos
-				| Some e1 ->
-					loop e1;
-					{ e.epos with pmax = e1.epos.pmin }
+			| Some e1 when origin <> TVOPatternVariable ->
+				loop e1;
+				{ e.epos with pmax = e1.epos.pmin }
+			| _ ->
+				e.epos
 			in
 			Hashtbl.replace vars v.v_id (v,p);
 		| TLocal ({v_kind = VUser _} as v) ->

+ 2 - 2
src/typing/matcher/texprConverter.ml

@@ -372,9 +372,9 @@ let to_texpr ctx t_switch with_type dt =
 						begin match bind.Bind.b_status with
 							| BindUsed ->
 								v_lookup := IntMap.add bind.b_var.v_id bind.b_expr !v_lookup;
-								Some (mk (TVar(bind.b_var,Some bind.b_expr)) com.basic.tvoid p)
+								Some (mk (TVar(bind.b_var,Some bind.b_expr)) com.basic.tvoid bind.b_pos)
 							| BindDeferred ->
-								Some (mk (TVar(bind.b_var,None)) com.basic.tvoid p)
+								Some (mk (TVar(bind.b_var,None)) com.basic.tvoid bind.b_pos)
 							| BindUnused ->
 								None
 						end