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

warning 45 doesn't play well with re-exported type definitions #6762

Closed
vicuna opened this issue Jan 29, 2015 · 4 comments
Closed

warning 45 doesn't play well with re-exported type definitions #6762

vicuna opened this issue Jan 29, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@vicuna
Copy link

vicuna commented Jan 29, 2015

Original bug ID: 6762
Reporter: @oandrieu
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2017-02-16T14:16:22Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.01.0
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @gasche @hcarty

Bug description

When 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)

File attachments

@vicuna
Copy link
Author

vicuna commented Nov 30, 2015

Comment author: @samoht

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)

@vicuna
Copy link
Author

vicuna commented Nov 30, 2015

Comment author: @alainfrisch

I've attached a tentative fix. Will test more and clean it up before committing.

@vicuna
Copy link
Author

vicuna commented Dec 1, 2015

Comment author: @alainfrisch

Fixed by commit 11ea50d.

@vicuna
Copy link
Author

vicuna commented Dec 1, 2015

Comment author: @gasche

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.

@vicuna vicuna closed this as completed Feb 16, 2017
@vicuna vicuna added this to the 4.03.0 milestone 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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants