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

Shadowing in a branch of a GADT match breaks unused variable warning #7115

Closed
vicuna opened this issue Jan 4, 2016 · 3 comments
Closed

Shadowing in a branch of a GADT match breaks unused variable warning #7115

vicuna opened this issue Jan 4, 2016 · 3 comments
Assignees

Comments

@vicuna
Copy link

@vicuna vicuna commented Jan 4, 2016

Original bug ID: 7115
Reporter: @sliquister
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2017-09-24T15:31:43Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.3
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Monitored by: @gasche

Bug description

The following code:

type t = A : t
let _apply_implementation t ~x =
match t with
| A -> let x = () in x

should complain about "unused variable x" but doesn't.
If instead [t] is defined as [type t = A], or if the two [x] variables are given different names, then we get:

$ ocamlopt -w +a /tmp/a.ml
File "/tmp/a.ml", line 2, characters 29-30:
Warning 27: unused variable x.

as expected.

@vicuna
Copy link
Author

@vicuna vicuna commented Jan 5, 2016

Comment author: @alainfrisch

Probably related to the function duplicate_ident_types in typecore.ml, which says:

    (* XXX This will mark the value as being used;
       I don't think this is what we want *)

@vicuna
Copy link
Author

@vicuna vicuna commented Jan 5, 2016

Comment author: @alainfrisch

Fix committed to trunk (4e8cb78). 'unused open' was similarly affected. I still don't understand the need to lookup the environment for existing bindings whose name match bound variables...

@vicuna
Copy link
Author

@vicuna vicuna commented Jan 5, 2016

Comment author: @sliquister

Thanks!

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