-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Doubtful "unused open" warning on module used for record field disambiguation #7443
Description
Original bug ID: 7443
Reporter: @gasche
Assigned to: @Octachron
Status: resolved (set by @gasche on 2016-12-29T19:08:47Z)
Resolution: fixed
Priority: normal
Severity: tweak
Version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: typing
Related to: #7386
Monitored by: @rixed
Bug description
The following code fails to compile with "-w @A" (setting all warnings as errors):
module M = struct
type t = { x : int; y : int }
end
let sum : M.t -> int = function
| M.{ x; y } -> x + y
The compiler complains that the opening "M." in the pattern M.{ x; y } is unused. But if I remove "M.", with the warning-as-errors setting, I still get a compilation error!
I believe that access to a module record field for disambiguation purposes should be counted as a "use" of this module. One might argue that this needs not be the case if neither warnings 40 or 42 are set, but I would personally still count it as a "use" in those cases -- I want to be able to write code that respects the 40-as-an-error principle even if 40 is not an error or even not set.
Additional information
This issue can easily be worked around by writing the pattern { M.x; y } instead, but I personally find M.{ x; y } more elegant and, beside, the warning behavior may surprise innocent bystanders -- hence it is arguably a usability bug.