Skip to content

warning on use of an identifier shadowed by module open -- feature implemented, but refinements still possible #5980

@vicuna

Description

@vicuna

Original bug ID: 5980
Reporter: @dbuenzli
Assigned to: @alainfrisch
Status: acknowledged (set by @gasche on 2016-10-14T20:19:58Z)
Resolution: reopened
Priority: normal
Severity: feature
Version: 4.00.1
Fixed in version: 4.01.0+dev
Category: typing
Has duplicate: #6428
Related to: #7386
Child of: #6951
Monitored by: @jmeber @hcarty

Bug description

While generally useful I think that the M.() notation may sometimes lead to subtle bugs when used as an expression.

Suppose I have M with this signature:

module M : sig
  type t 
  val id : t 
  val ( + ) : t -> t -> t
  ...
end

And I code this function:

let f () = 
  let (id : t) = ... in 
  let (c : t) = ... in 
  M.(id + c) 

I would like a warning that tells me that in M.(id + c), id is overriding a local variable. Note that a few cases are already covered by current warnings/errors.

  1. If the local id not used elsewhere in f you will have (an initially puzzling) unused variable warning -- however that warning doesn't cover pattern matching variables.

  2. If M.id was of another type you'd get an (aswell puzzling) type mismatch error.

I think that failing to have such a warning by default somehow renders all M.(e), where e binds local variables quite brittle and suspicious.

Thanks,

Daniel

Additional information

[Gabriel Scherer]: I reopened this bug to track the suggestion from Peter Urkedal reported in

#5980#c14317

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions