Skip to content

Commit

Permalink
[display] fix range of pattern variables
Browse files Browse the repository at this point in the history
see #7282
  • Loading branch information
Simn committed Nov 21, 2023
1 parent 486dfc8 commit 160a490
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/context/display/diagnostics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down
4 changes: 2 additions & 2 deletions src/typing/matcher/texprConverter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 160a490

Please sign in to comment.