Skip to content

Commit 9f304d8

Browse files
authored
flambda-backend: Adjust the location on as pattern vars for better errors/warnings (#1835)
This adjusts the location on as patterns for better errors/warnings
1 parent b9cf106 commit 9f304d8

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

testsuite/tests/typing-gadts/or_patterns.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ let simple_merged_annotated_return (type a) (t : a t) (a : a) =
217217
;;
218218

219219
[%%expect{|
220-
Line 3, characters 12-20:
220+
Line 3, characters 18-19:
221221
3 | | IntLit, (3 as x)
222-
^^^^^^^^
222+
^
223223
Error: This pattern matches values of type a
224224
This instance of a is ambiguous:
225225
it would escape the scope of its equation

testsuite/tests/warnings/w26_alias.ml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(* TEST
2+
* expect
3+
*)
4+
type t =
5+
{ x : int
6+
; y : int
7+
}
8+
9+
let sum ({ x; y } as t) = x + y
10+
11+
[%%expect{|
12+
type t = { x : int; y : int; }
13+
Line 6, characters 21-22:
14+
6 | let sum ({ x; y } as t) = x + y
15+
^
16+
Warning 26 [unused-var]: unused variable t.
17+
val sum : t -> int = <fun>
18+
|}]
19+

typing/typecore.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ and type_pat_aux
25402540
let ty_var, mode = solve_Ppat_alias ~refine ~mode:alloc_mode.mode env q in
25412541
let mode = mode_cross_to_min !env expected_ty mode in
25422542
let id =
2543-
enter_variable ~is_as_variable:true tps loc name mode
2543+
enter_variable ~is_as_variable:true tps name.loc name mode
25442544
ty_var sp.ppat_attributes
25452545
in
25462546
rvp k {

0 commit comments

Comments
 (0)