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

Proposal: flag duplicate parameters as error #7029

Closed
vicuna opened this issue Oct 22, 2015 · 4 comments
Closed

Proposal: flag duplicate parameters as error #7029

vicuna opened this issue Oct 22, 2015 · 4 comments

Comments

@vicuna
Copy link

vicuna commented Oct 22, 2015

Original bug ID: 7029
Reporter: @bobzhang
Assigned to: @garrigue
Status: closed (set by @garrigue on 2016-12-13T00:34:17Z)
Resolution: duplicate
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Duplicate of: #4904

Bug description

It feels a bit weird that this code works in OCaml

let f x x = x

I am not sure that if we have a use case of duplicate parameters? The motivating example is that for the javascript backend, I would like to provide a guarantee that all names of parameters are preserved(which is very useful for stacktrace and debugger), however, ES5 strict mode does not allow duplicate parameters, it would be nice that OCaml is stricter than Javascript : )

@vicuna
Copy link
Author

vicuna commented Oct 22, 2015

Comment author: @gasche

Having a warning in that case would be fine, and it could be enabled by default¹. I'm not convinced it is a good idea to make it an error, as it could break code for no excellent reason.

¹: such code always raises warning 27, "unused variable", but this warning is not enabled by default as it would be too noisy for some codebases.

The reason this should remain allowed is that it is a natural consequence of currification: "let f = fun x -> fun x -> x" shadows a first variable of name "x" with another of name "x".

@vicuna
Copy link
Author

vicuna commented Oct 22, 2015

Comment author: @bobzhang

let f = fun x -> fun x -> ... would probably be a bug

let f = fun x -> let y = 32 ... in fun x -> ... this seems to be good

can we have a warning for duplicated parameters which is more server than unused varaibles

@vicuna
Copy link
Author

vicuna commented Oct 23, 2015

Comment author: @lefessan

I am not convinced by the use-case: when you generate the Javascript, you can check if the variables have the same name, and change the name of the unused one (to "x_unused_1", anyway, you won't need to debug it, as it is unused).

@vicuna
Copy link
Author

vicuna commented Dec 13, 2016

Comment author: @garrigue

I'm closing this one, as it is a duplicate of #4904.
People who want to discuss should do it there.

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

No branches or pull requests

2 participants