Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007115OCamltypingpublic2016-01-04 21:152017-09-24 17:31
Reportersliquister 
Assigned Tofrisch 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version4.02.3 
Target VersionFixed in Version4.03.0+dev / +beta1 
Summary0007115: Shadowing in a branch of a GADT match breaks unused variable warning
DescriptionThe 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.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0015223)
frisch (developer)
2016-01-05 09:28

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 *)
(0015224)
frisch (developer)
2016-01-05 11:13
edited on: 2016-01-05 11:19

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

(0015226)
sliquister (reporter)
2016-01-05 13:24

Thanks!

- Issue History
Date Modified Username Field Change
2016-01-04 21:15 sliquister New Issue
2016-01-05 09:28 frisch Note Added: 0015223
2016-01-05 10:41 frisch Assigned To => frisch
2016-01-05 10:41 frisch Status new => assigned
2016-01-05 11:13 frisch Note Added: 0015224
2016-01-05 11:19 frisch Note Edited: 0015224 View Revisions
2016-01-05 13:24 sliquister Note Added: 0015226
2016-01-05 14:33 frisch Status assigned => resolved
2016-01-05 14:33 frisch Fixed in Version => 4.03.0+dev / +beta1
2016-01-05 14:33 frisch Resolution open => fixed
2017-02-23 16:45 doligez Category OCaml typing => typing
2017-09-24 17:31 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker