| Anonymous | Login | Signup for a new account | 2013-05-21 08:09 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||
| 0004073 | OCaml | OCaml general | public | 2006-07-28 10:06 | 2006-09-21 16:34 | |||
| Reporter | prevosto | |||||||
| Assigned To | maranget | |||||||
| Priority | normal | Severity | tweak | Reproducibility | always | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | 3.09.2 | |||||||
| Target Version | Fixed in Version | |||||||
| Summary | 0004073: Spurious 'E' warning (fragile pattern-matching) | |||||||
| 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 = <fun> # 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 = <fun> 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 = <fun> | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0003794) maranget (manager) 2006-09-21 16:34 |
I think I have closed the issue. Fragile matchings are no implemented by following definition. A matching is said to be fragile when the addition of a constructor to one of the types it matches does not result in a 'non-exhaustive' warning. 'One of the types it matches' means that there is a constructor that belongs to the said type in the matching. Before, there was a vague notion of 'fragile pattern' with no clear meaning. --Luc |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2006-07-28 10:06 | prevosto | New Issue | |
| 2006-08-29 16:54 | doligez | Status | new => acknowledged |
| 2006-09-20 19:12 | maranget | Status | acknowledged => assigned |
| 2006-09-20 19:12 | maranget | Assigned To | => maranget |
| 2006-09-21 16:34 | maranget | Note Added: 0003794 | |
| 2006-09-21 16:34 | maranget | Status | assigned => closed |
| 2006-09-21 16:34 | maranget | Resolution | open => fixed |
| Copyright © 2000 - 2011 MantisBT Group |