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: 4073 Reporter: prevosto Assigned to:@maranget Status: closed (set by @maranget on 2006-09-21T14:34:34Z) Resolution: fixed Priority: normal Severity: tweak Version: 3.09.2 Category: ~DO NOT USE (was: OCaml general) Monitored by: prevosto
Bug description
In certain cases, ocaml warns that a matching is fragile while it isn't:
is002447:~ $ ocaml -w E
Objective Caml version 3.09.2
type foo = A | B;;
type foo = A | B
let f = function A,_ | _, A -> A | B,B -> B;;
val f : foo * foo -> foo =
let f = function A,_ -> A | _,A -> A | B,B -> B;;
Characters 28-29:
Warning E: this pattern is fragile. It would hide
the addition of new constructors to the data types it matches.
let f = function A,_ -> A | _,A -> A | B,B -> B;;
^
val f : foo * foo -> foo =
The two definitions of f are equivalent. Moreover, if we indeed add a constructor, the matching becomes incomplete (but it is flagged as fragile, which is a bit contradictory):
type bar = A | B | C;;
type bar = A | B | C
let f = function A,_ -> A | _,A -> A | B,B -> B;;
Characters 10-49:
Warning P: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
(C, (C|B))
Characters 30-31:
Warning E: this pattern is fragile. It would hide
the addition of new constructors to the data types it matches.
let f = function A,_ -> A | ,A -> A | B,B -> B;;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
let f = function A, -> A | _,A -> A | B,B -> B;;
^
val f : bar * bar -> bar =
The text was updated successfully, but these errors were encountered:
Original bug ID: 4073
Reporter: prevosto
Assigned to: @maranget
Status: closed (set by @maranget on 2006-09-21T14:34:34Z)
Resolution: fixed
Priority: normal
Severity: tweak
Version: 3.09.2
Category: ~DO NOT USE (was: OCaml general)
Monitored by: prevosto
Bug description
In certain cases, ocaml warns that a matching is fragile while it isn't:
is002447:~ $ ocaml -w E
Objective Caml version 3.09.2
type foo = A | B;;
type foo = A | B
let f = function A,_ | _, A -> A | B,B -> B;;
val f : foo * foo -> foo =
let f = function A,_ -> A | _,A -> A | B,B -> B;;
Characters 28-29:
Warning E: this pattern is fragile. It would hide
the addition of new constructors to the data types it matches.
let f = function A,_ -> A | _,A -> A | B,B -> B;;
^
val f : foo * foo -> foo =
The two definitions of f are equivalent. Moreover, if we indeed add a constructor, the matching becomes incomplete (but it is flagged as fragile, which is a bit contradictory):
type bar = A | B | C;;
type bar = A | B | C
let f = function A,_ -> A | _,A -> A | B,B -> B;;
Characters 10-49:
Warning P: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
(C, (C|B))
Characters 30-31:
Warning E: this pattern is fragile. It would hide
the addition of new constructors to the data types it matches.
let f = function A,_ -> A | ,A -> A | B,B -> B;;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
let f = function A, -> A | _,A -> A | B,B -> B;;
^
val f : bar * bar -> bar =
The text was updated successfully, but these errors were encountered: