Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
propagate type information to patterns, even when there are polymorph…
…ic variants git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13221 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
- Loading branch information
garrigue
committed
Jan 11, 2013
1 parent
531a981
commit cc0e2da
Showing
7 changed files
with
136 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 15 additions & 4 deletions
19
testsuite/tests/typing-misc/polyvars.ml.principal.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
|
||
# type ab = [ `A | `B ] | ||
# val f : [ `A ] -> int = <fun> | ||
# val f : [ `A ] -> unit = <fun> | ||
# Characters 32-35: | ||
let f (x : [`A]) = match x with #ab -> 1;; | ||
^^^ | ||
Error: This pattern matches values of type [? `A | `B ] | ||
but a pattern was expected which matches values of type [ `A ] | ||
The second variant type does not allow tag(s) `B | ||
# Characters 31-34: | ||
let f x = ignore (match x with #ab -> 1); ignore (x : [`A]);; | ||
^^^ | ||
Error: This pattern matches values of type [? `B ] | ||
but a pattern was expected which matches values of type [ `A ] | ||
Types for tag `B are incompatible | ||
# Characters 34-36: | ||
let f x = ignore (match x with `A|`B -> 1); ignore (x : [`A]);; | ||
^^ | ||
Warning 12: this sub-pattern is unused. | ||
val f : [ `A ] -> unit = <fun> | ||
Error: This pattern matches values of type [? `B ] | ||
but a pattern was expected which matches values of type [ `A ] | ||
Types for tag `B are incompatible | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
|
||
# type ab = [ `A | `B ] | ||
# val f : [ `A ] -> int = <fun> | ||
# val f : [ `A ] -> unit = <fun> | ||
# Characters 32-35: | ||
let f (x : [`A]) = match x with #ab -> 1;; | ||
^^^ | ||
Error: This pattern matches values of type [? `A | `B ] | ||
but a pattern was expected which matches values of type [ `A ] | ||
The second variant type does not allow tag(s) `B | ||
# Characters 31-34: | ||
let f x = ignore (match x with #ab -> 1); ignore (x : [`A]);; | ||
^^^ | ||
Error: This pattern matches values of type [? `B ] | ||
but a pattern was expected which matches values of type [ `A ] | ||
The second variant type does not allow tag(s) `B | ||
# Characters 34-36: | ||
let f x = ignore (match x with `A|`B -> 1); ignore (x : [`A]);; | ||
^^ | ||
Warning 12: this sub-pattern is unused. | ||
val f : [ `A ] -> unit = <fun> | ||
Error: This pattern matches values of type [? `B ] | ||
but a pattern was expected which matches values of type [ `A ] | ||
The second variant type does not allow tag(s) `B | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters