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

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

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

This comment has been minimized.

Copy link
Collaborator Author

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

This comment has been minimized.

Copy link
Collaborator Author

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

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 5, 2016

Comment author: @sliquister

Thanks!

@vicuna vicuna closed this Sep 24, 2017

@vicuna vicuna added the typing label Mar 14, 2019

@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.