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: 5267 Reporter: Dmitry Grebeniuk Status: closed (set by @diml on 2016-12-07T17:27:37Z) Resolution: open Priority: normal Severity: minor Version: 3.13.0+dev Target version: later Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Bug description
type t1 = [ A of int ];
type t1 = [ A of int ]
fun [ A "a" True -> () ];
Characters 6-16:
fun [ A "a" True -> () ];
^^^^^^^^^^
Error: This pattern matches values of type (string * bool)
but a pattern was expected which matches values of type int
The error here should be more like to "Error: The constructor A expects 1 argument(s), but is applied here to 2 argument(s)"
Maybe this is a minor issue itself, but it leads to very hard to find errors when the wrong type infers from pattern matching and spreads all over the code:
type t 'a = [ T of 'a ];
type t 'a = [ T of 'a ]
value f x = match x with [ T a b -> a ];
value f : t ('a * 'b) -> 'a =
The text was updated successfully, but these errors were encountered:
This is not really a camlp4 problem, because the compiler does automatic tuplification of constructor arguments when you pass several arguments to a unary constructor:
$ ocaml
Objective Caml version 3.12.1
type t1 = A of int;;
type t1 = A of int
function A ("a", true) -> ();;
Error: This pattern matches values of type string * bool
but a pattern was expected which matches values of type int
Definitely not a camlp4 problem. We could have a better error message for the first example, but there's nothing we can do to prevent propagation in the second example.
Original bug ID: 5267
Reporter: Dmitry Grebeniuk
Status: closed (set by @diml on 2016-12-07T17:27:37Z)
Resolution: open
Priority: normal
Severity: minor
Version: 3.13.0+dev
Target version: later
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Bug description
type t1 = [ A of int ];
type t1 = [ A of int ]
fun [ A "a" True -> () ];
Characters 6-16:
fun [ A "a" True -> () ];
^^^^^^^^^^
Error: This pattern matches values of type (string * bool)
but a pattern was expected which matches values of type int
The error here should be more like to "Error: The constructor A expects 1 argument(s), but is applied here to 2 argument(s)"
Maybe this is a minor issue itself, but it leads to very hard to find errors when the wrong type infers from pattern matching and spreads all over the code:
type t 'a = [ T of 'a ];
type t 'a = [ T of 'a ]
value f x = match x with [ T a b -> a ];
value f : t ('a * 'b) -> 'a =
The text was updated successfully, but these errors were encountered: