Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005267OCamlCamlp4public2011-05-17 07:492013-07-27 06:45
ReporterDmitry Grebeniuk 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version3.13.0+dev 
Target VersionlaterFixed in Version 
Summary0005267: camlp4r (?) does not respect the constructor's arity
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 = <fun>
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0007687)
doligez (administrator)
2012-07-10 15:09

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
#
(0008128)
doligez (administrator)
2012-09-20 16:19

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.

- Issue History
Date Modified Username Field Change
2011-05-17 07:49 Dmitry Grebeniuk New Issue
2011-05-17 07:49 Dmitry Grebeniuk Status new => assigned
2011-05-17 07:49 Dmitry Grebeniuk Assigned To => ertai
2011-10-26 08:35 ertai Assigned To ertai => xclerc
2012-07-10 15:09 doligez Note Added: 0007687
2012-07-10 15:09 doligez Target Version => 4.01.0+dev
2012-07-31 13:36 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-20 16:19 doligez Note Added: 0008128
2012-09-20 16:19 doligez Assigned To xclerc =>
2012-09-20 16:19 doligez Status assigned => acknowledged
2012-09-20 16:19 doligez Target Version 4.00.1+dev => 4.01.0+dev
2013-07-27 06:45 gasche Target Version 4.01.0+dev => later


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker