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: 109 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
let f x = match x with spam 3 -> 29 | spam "spat" -> 23;;
causes the compiler to halt and generate the following error message:
Uncaught exception: File "typing/parmatch.ml", line 0, characters
16649-16661:
Assertion failed
Well, the current definition is a bit ambiguous about what is valid or not.
In particular, the definition
let f1 = function `spam 3 -> 29
let f2 = function `spam "spat" -> 23
let f x = f1 x + f2 x
val f1 : [< `spam of int] -> int = <fun>
val f2 : [< `spam of string] -> int = <fun>
val f : [< `spam of string & int] -> int = <fun>
is explicitly described as valid, while it is of course meaningless.
The bug you report could be solved in two ways:
either decide that this is valid, and just produces an unusable function.
This requires compiling it to some arbitrary code, and would make some
parts of the compiler rather dirty.
or explicitly say that while variant types with conjunctive types are allowed
in expressions, they are not allowed in patterns. This gives a more
intuitive behaviour, with useful error messages.
I think that the second solution is better, and I have implemented it
in the CVS version, by using a stricter form of unification on pattern types.
However this gives raise to some philosophical questions about what are the
theoretical properties expected when typing patterns, and how this interacts
with the typing of expressions. This change is subject to theory and
implementation improvements.
Original bug ID: 109
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: David Clarke
Version: 3.00
OS: SunOS
Submission from: cache2.uwn.unsw.edu.au (129.94.6.29)
The following code (which is invalid):
let f x = match x with
spam 3 -> 29 |
spam "spat" -> 23;;causes the compiler to halt and generate the following error message:
Uncaught exception: File "typing/parmatch.ml", line 0, characters 16649-16661:
Assertion failed
The text was updated successfully, but these errors were encountered: