-
Notifications
You must be signed in to change notification settings - Fork 89
[%call_pos]
application via an optional argument results in an error
#2497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
goldfirere
merged 11 commits into
ocaml-flambda:main
from
Enoumy:call-pos-optional-application
May 1, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
041b868
Added test case showing unhandled optional application
Enoumy bb38a1c
Removed warning when [%call_pos] is applied optionally
Enoumy 3af6424
Fixed! Cleanup still pending - unsure if my approach is sound...
Enoumy d032e20
Clearer object system test
Enoumy 1c6b50e
Add test case on object system that is still failing
Enoumy b92436e
preserve guard order
Enoumy 0118f39
Fixed object system application
Enoumy 4207455
Deduplicated optional application function
Enoumy ff28479
Turned applying a [%call_pos] argument into an error after discussion.
Enoumy 8057c57
Address comments during review
Enoumy e75e7d3
Small refactor lowering line lengths more
Enoumy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
ocaml/testsuite/tests/typing-implicit-source-positions/application_via_option.ml
This file contains hidden or 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,119 @@ | ||
(* TEST_BELOW | ||
Fille | ||
*) | ||
|
||
let f = fun ~(call_pos:[%call_pos]) () -> call_pos | ||
[%%expect {| | ||
val f : call_pos:[%call_pos] -> unit -> lexing_position = <fun> | ||
|}] | ||
|
||
let _ = f ?call_pos:None (); | ||
[%%expect {| | ||
Line 1, characters 20-24: | ||
1 | let _ = f ?call_pos:None (); | ||
^^^^ | ||
Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in | ||
automatically if ommitted. It cannot be passed with '?'. | ||
|}] | ||
|
||
let _ = | ||
let pos = f () in | ||
f ?call_pos:(Some pos) (); | ||
[%%expect {| | ||
Line 3, characters 14-24: | ||
3 | f ?call_pos:(Some pos) (); | ||
^^^^^^^^^^ | ||
Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in | ||
automatically if ommitted. It cannot be passed with '?'. | ||
|}] | ||
|
||
let ( >>| ) ~(call_pos : [%call_pos]) a b = a + b, call_pos ;; | ||
[%%expect {| | ||
val ( >>| ) : call_pos:[%call_pos] -> int -> int -> int * lexing_position = | ||
<fun> | ||
|}] | ||
|
||
let _ = ( >>| ) ?call_pos:None 1 2 ;; | ||
[%%expect {| | ||
Line 1, characters 27-31: | ||
1 | let _ = ( >>| ) ?call_pos:None 1 2 ;; | ||
^^^^ | ||
Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in | ||
automatically if ommitted. It cannot be passed with '?'. | ||
|}] | ||
|
||
let _ = | ||
let pos = f () in | ||
( >>| ) ?call_pos:(Some pos) 1 2 | ||
;; | ||
[%%expect {| | ||
Line 3, characters 20-30: | ||
3 | ( >>| ) ?call_pos:(Some pos) 1 2 | ||
^^^^^^^^^^ | ||
Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in | ||
automatically if ommitted. It cannot be passed with '?'. | ||
|}] | ||
|
||
class c ~(call_pos : [%call_pos]) () = object | ||
method call_pos = call_pos | ||
end | ||
[%%expect {| | ||
class c : | ||
call_pos:[%call_pos] -> | ||
unit -> object method call_pos : lexing_position end | ||
|}] | ||
|
||
let _ = (new c ?call_pos:None ())#call_pos;; | ||
[%%expect {| | ||
Line 1, characters 25-29: | ||
1 | let _ = (new c ?call_pos:None ())#call_pos;; | ||
^^^^ | ||
Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in | ||
automatically if ommitted. It cannot be passed with '?'. | ||
|}] | ||
|
||
let _ = | ||
let pos = f () in | ||
(new c ?call_pos:(Some pos) ())#call_pos;; | ||
[%%expect {| | ||
Line 3, characters 19-29: | ||
3 | (new c ?call_pos:(Some pos) ())#call_pos;; | ||
^^^^^^^^^^ | ||
Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in | ||
automatically if ommitted. It cannot be passed with '?'. | ||
|}] | ||
|
||
class parent ~(call_pos : [%call_pos]) () = object | ||
method pos = call_pos | ||
end | ||
[%%expect {| | ||
class parent : | ||
call_pos:[%call_pos] -> unit -> object method pos : lexing_position end | ||
|}] | ||
|
||
let _ = (object | ||
inherit parent ?call_pos:None () | ||
end)#pos;; | ||
[%%expect {| | ||
Line 2, characters 27-31: | ||
2 | inherit parent ?call_pos:None () | ||
^^^^ | ||
Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in | ||
automatically if ommitted. It cannot be passed with '?'. | ||
|}] | ||
|
||
let o = (object | ||
inherit parent ?call_pos:(Some (f ())) () | ||
end)#pos | ||
[%%expect {| | ||
Line 2, characters 27-40: | ||
2 | inherit parent ?call_pos:(Some (f ())) () | ||
^^^^^^^^^^^^^ | ||
Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in | ||
automatically if ommitted. It cannot be passed with '?'. | ||
|}] | ||
|
||
|
||
(* TEST | ||
expect; | ||
*) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.