-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the location that [%call_pos] points at.
[%call_pos] used to point to the location of the entire function application. This resulted in instances like: ```ocaml (* f : here:[%call_pos] -> unit -> unit *) () |> f |> f ``` where both [f]'s had the same location. This is fixed in this commit by making [%call_pos] use the location of the function instead of the location of the entire application.
- Loading branch information
Showing
4 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
ocaml/testsuite/tests/typing-implicit-source-positions/rev_apply_correct_location.ml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(* TEST | ||
expect; | ||
*) | ||
|
||
let f ~(here : [%call_pos]) x = here, x | ||
|
||
[%%expect | ||
{| | ||
val f : here:[%call_pos] -> 'a -> lexing_position * 'a = <fun> | ||
|}] | ||
|
||
let result = () |> f |> f | ||
|
||
(* Importantly, these locations are different. *) | ||
[%%expect | ||
{| | ||
val result : lexing_position * (lexing_position * unit) = | ||
({pos_fname = ""; pos_lnum = 1; pos_bol = 145; pos_cnum = 169}, | ||
({pos_fname = ""; pos_lnum = 1; pos_bol = 145; pos_cnum = 164}, ())) | ||
|}] | ||
|
||
class ['a] c : here:[%call_pos] -> 'a -> object | ||
method here : lexing_position * 'a | ||
end = fun ~(here : [%call_pos]) a -> object | ||
method here = here, a | ||
end | ||
|
||
[%%expect{| | ||
class ['a] c : | ||
here:[%call_pos] -> 'a -> object method here : lexing_position * 'a end | ||
|}] | ||
|
||
let obj = (() |> new c |> new c) | ||
|
||
let second_here = fst obj#here | ||
let first_here = fst (snd obj#here)#here | ||
|
||
|
||
[%%expect{| | ||
val obj : unit c c = <obj> | ||
val second_here : lexing_position = | ||
{pos_fname = ""; pos_lnum = 1; pos_bol = 710; pos_cnum = 736} | ||
val first_here : lexing_position = | ||
{pos_fname = ""; pos_lnum = 1; pos_bol = 710; pos_cnum = 727} | ||
|}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters