You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
I just noticed (in real code) that this also happens with variant constructor disambiguation:
module M = struct
type t = A | B | C
end
let sum : M.t -> unit = function
| M.(A | B | C) -> ()
Again the compiler complains that "M." is unused. This is again wrong and, furthermore, there is no workaround as in the record case -- at least as long as 7386 is not resolved.
I can confirm that the fix by octachron in #990 fixed the problem -- I tested those two examples.
I should have realized that this was not an issue with "open" in general, but with the new pattern-open feature, as "let open M in function A | B | C -> ()" does not warn -- I failed to try.
Thanks octachron for the quick fix and the nice feature.
This fix doesn't look correct to me. It looks as though it just turns off the unused open warning for opens in patterns, which is not the desired behaviour.
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.
The text was updated successfully, but these errors were encountered: