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

Confusing errors / lack of errors with labelled arguments #6580

Closed
vicuna opened this issue Sep 25, 2014 · 3 comments
Closed

Confusing errors / lack of errors with labelled arguments #6580

vicuna opened this issue Sep 25, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@vicuna
Copy link

vicuna commented Sep 25, 2014

Original bug ID: 6580
Reporter: @johnwhitington
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:47:28Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 4.02.1+dev
Target version: 4.02.3+dev
Category: ~DO NOT USE (was: OCaml general)
Child of: #5903
Monitored by: @gasche

Bug description

Consider, in 4.02 (We need a product version for that in the tracker...)

let f ~(x:bool) y = x
val f : x:bool -> 'a -> bool =

If we omit the parentheses, we get a not terribly useful error:

let f ~x:bool y = x;;

Error: Unbound value x

But worse, if we don't mention 'x' at all in the body, it is given type 'a rather than bool, and we get no error!

let f ~x:bool y = y;;

val f : x:'a -> 'b -> 'b =

These two errors both seem unoptimal and, worse, at odds with one another...

@vicuna
Copy link
Author

vicuna commented Sep 25, 2014

Comment author: @garrigue

I do not really see what we can improve.
~(x:bool) is just a shorthand for ~x:(x:bool),
I.e. a variable x of type bool with label x.

~x:bool (without space in ~x: ) is legal and denotes an argument of name (not type) bool, with label x.
Three is no variable x involved.

I think this explains all the behaviors you observed.

@vicuna
Copy link
Author

vicuna commented Sep 25, 2014

Comment author: @johnwhitington

Jacques, you're quite right of course!

Some sort of "unused variable" warning for the name 'bool' would help though?

@vicuna
Copy link
Author

vicuna commented Sep 25, 2014

Comment author: @garrigue

Yes, the remark about unused variable warnings coming too late is already in #5903.
Unfortunately, currently one needs to typecheck the whole expression before issuing such warning.
Giving the warnings early would require an independent binding analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants