Skip to content
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

"Optional argument cannot be erased" warning is not issued when an optional argument is followed only by labeled arguments #5342

Closed
vicuna opened this Issue Aug 18, 2011 · 4 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Aug 18, 2011

Original bug ID: 5342
Reporter: elnatan
Assigned to: @garrigue
Status: closed (set by @garrigue on 2011-12-14T09:22:01Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.12.0
Fixed in version: 3.13.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @ygrek

Bug description

An optional argument that is followed by labeled arguments but by no anonymous arguments cannot be erased, but no warning is issued.

let f ?x ~y = x,y;;

val f : ?x:'a -> y:'b -> 'a option * 'b =

f ~y:();;

  • : ?x:'a -> 'a option * unit =
@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Aug 24, 2011

Comment author: lavi

Well, It can be erased, but without any label:

let f ?x ~y = x,y;;

val f : ?x:'a -> y:'b -> 'a option * 'b =

f 1;;

  • : 'a option * int = (None, 1)
@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 10, 2011

Comment author: @garrigue

As pointed out in the note, in can be erased by passing all non-optional arguments without labels.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 12, 2011

Comment author: elnatan

This is true, but then I think the manual needs correction: http://caml.inria.fr/pub/docs/manual-ocaml/manual006.html says, 'A function taking some optional arguments must also take at least one non-labeled argument.'

Also, when warning 6 ('labels were omitted in the application of this function.') is treated as an error, it would helpful to have the unerasable optional argument warning when an optional argument is followed by only labeled arguments.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 14, 2011

Comment author: @garrigue

Fixed the manual, revision 11310.

@vicuna vicuna closed this Dec 14, 2011

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.