Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006762OCaml~DO NOT USE (was: OCaml general)public2015-01-29 11:262017-02-16 15:16
Reporteroandrieu 
Assigned Tofrisch 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version4.01.0 
Target Version4.03.0+dev / +beta1Fixed in Version4.03.0+dev / +beta1 
Summary0006762: warning 45 doesn't play well with re-exported type definitions
DescriptionWhen a variant type is re-exported in another module, opening both modules triggers the "open statement shadows the constructor". One could argue that it's not really a case of shadowing since it's the types are equivalent.
Steps To Reproduce$ cat t.ml
type tau =
 | Tbool
 | Tint

$ cat t2.ml
type tau = T.tau =
 | Tbool
 | Tint

$ cat t3.ml
open T
open T2

let is_bool = function
  | Tbool -> true
  | Tint -> false

$ ocamlopt -w +45 -c t.ml t2.ml t3.ml
File "t3.ml", line 2, characters 0-7:
Warning 45: this open statement shadows the constructor Tbool (which is later used)
File "t3.ml", line 2, characters 0-7:
Warning 45: this open statement shadows the constructor Tint (which is later used)
TagsNo tags attached.
Attached Filesdiff file icon fix_6762.diff [^] (7,111 bytes) 2015-12-01 00:30 [Show Content]

- Relationships

-  Notes
(0014923)
samoht (reporter)
2015-11-30 22:00

I have the same problem with the new result type. I am using @dbuenzli Rresult which propagate the type equality:

type ('a, 'b) result = ('a, 'b) Result.result = Ok of 'a | Error of 'b
https://github.com/dbuenzli/rresult/blob/master/src/rresult.mli#L26 [^]

When I try to compile my programs with trunk, I got:

File "lib/functoria_misc.ml", line 18, characters 0-12:
Warning 45: this open statement shadows the constructor Ok (which is later used)
File "lib/functoria_misc.ml", line 18, characters 0-12:
Warning 45: this open statement shadows the constructor Error (which is later used)
(0014929)
frisch (developer)
2015-12-01 00:31

I've attached a tentative fix. Will test more and clean it up before committing.
(0014931)
frisch (developer)
2015-12-01 09:36

Fixed by commit 11ea50d8e20ab52b2df92fbab66e048d98bd6073.
(0014933)
gasche (administrator)
2015-12-01 10:06

Thanks Alain! Your patch is clean and opens the door to a principled policy of not warning when the shadowing identifier is an alias of the shadowed one, which we have already mentioned several times for terms and modules alike.

- Issue History
Date Modified Username Field Change
2015-01-29 11:26 oandrieu New Issue
2015-02-20 23:12 doligez Status new => acknowledged
2015-02-20 23:12 doligez Target Version => 4.03.0+dev / +beta1
2015-11-30 22:00 samoht Note Added: 0014923
2015-12-01 00:30 frisch File Added: fix_6762.diff
2015-12-01 00:31 frisch Note Added: 0014929
2015-12-01 09:36 frisch Assigned To => frisch
2015-12-01 09:36 frisch Status acknowledged => assigned
2015-12-01 09:36 frisch Note Added: 0014931
2015-12-01 09:36 frisch Status assigned => resolved
2015-12-01 09:36 frisch Fixed in Version => 4.03.0+dev / +beta1
2015-12-01 09:36 frisch Resolution open => fixed
2015-12-01 10:06 gasche Note Added: 0014933
2017-02-16 15:16 xleroy Status resolved => closed
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker