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

Add warning for [f ?a ~b] and similar #7837

Open
vicuna opened this Issue Aug 10, 2018 · 2 comments

Comments

Projects
None yet
1 participant
@vicuna
Copy link
Collaborator

vicuna commented Aug 10, 2018

Original bug ID: 7837
Reporter: jtsang
Status: new
Resolution: open
Priority: normal
Severity: feature
Category: typing
Monitored by: @nojb

Bug description

Warning 16 covers cases where an optional argument is at the end of a function type, where it cannot be erased.

In #7836 it was determined that if the optional argument is followed by only labeled arguments, warning 16 does not apply because the special case for total application can erase the optional argument.

I.e. for

let f ?a ~b = ()

the function call

f ()

(and not f ~b:()) will succeed in erasing ?a.

However, under the circumstances of enabling warning 6 (label was omitted in the application of function) and warnings to errors, it is again statically impossible to call f without the optional argument.

I would like to propose a separate warning for this case, with a message similar to:

Warning #: this optional argument can only be erased by totally applying the function while omitting all labels

and if possible, enabling warning 6 should imply this hypothetical new warning.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Aug 11, 2018

Comment author: @nojb

I am a bit skeptical about adding a new warning for this. What about triggering warning 16 in this situation if warning 6 is active and made into an error?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Aug 13, 2018

Comment author: jtsang

This is certainly a solution, but I'm wary of making the semantics of warnings depend on the state of other warnings.

Additionally, warning 6/-Werr is at the call site, whereas this is at the definition point, so it might not be consistent between the two.

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.