Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006440OCamlCamlp4public2014-05-22 21:202014-05-23 18:43
Reporterlabichn 
Assigned Todim 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
Platformx86_64OSGNU/LinuxOS Version3.14.4-1-ARCH
Product Version4.01.0 
Target VersionFixed in Version 
Summary0006440: Preprocessor issues with polymorphic variants
DescriptionThere seems to be inconsistent behavior involving the "-pp" flag of ocamlc. Under some conditions with polymorphic variants and private row types, using the "-pp" flag (as opposed to first running caml4p and then ocamlc) causes an incorrect error.
Steps To Reproduce> cat garrigue.ml # attached to the bug report
(* example modified from Garrigue, J.--APLAS '06 *)
module type Ops = sig
  type expr
  val eval : expr -> expr
  val show : expr -> string
end
module Test = struct
  type 'a expr0 = [`Num of int | `True]
  module F(X : Ops with type expr = private [> 'a expr0] as 'a) =
  struct
    type expr = X.expr expr0
    let eval : expr -> X.expr = function
      | `True -> `True
      | `Num _ as e -> e
    let show : expr -> string = function
      | `Num n -> string_of_int n
      | `True -> "true"
  end
  module rec L : (Ops with type expr = L.expr expr0) = F(L)
end
let _ = Printf.printf "%s\n" (Test.L.show(`True)) ;;
> wget http://caml.inria.fr/pub/distrib/ocaml-4.01/ocaml-4.01.0.tar.gz [^]
> tar -xf ocaml-4.01.0.tar.gz
> cd ocaml-4.01.0.tar.gz
> ./configure --prefix $PWD/local && make world.opt && make install
...
> cd ..
> ./ocaml-4.01.0/local/bin/ocamlc -pp "./ocaml-4.01.0/local/bin/camlp4o" garrigue.ml
File "garrigue.ml", line 14, characters 8-13:
Error: This pattern matches values of type [? `True ]
       but a pattern was expected which matches values of type expr
       The second variant type does not allow tag(s) `True
> ./ocaml-4.01.0/local/bin/camlp4o garrigue.ml > pp_garrigue.ml
> ./ocaml-4.01.0/local/bin/ocamlc pp_garrigue.ml
> ./a.out
true
Additional InformationIt only seems to occur if the pv constructor has no arguments; if you remove `True from the type and the relevant cases from the functions, there is no issue. This issue seems to be present in 3.12.1, 4.01.0, and the current latest on github (as of May 22nd @ 15:00).
TagsNo tags attached.
Attached Files? file icon garrigue.ml [^] (620 bytes) 2014-05-22 21:20 [Show Content]

- Relationships

-  Notes
(0011554)
dim (developer)
2014-05-22 21:29

Yes, it's a known issue of camlp4 and is hard to fix. Could you report this on the camlp4 tracker on github?

  https://github.com/ocaml/camlp4 [^]
(0011555)
labichn (reporter)
2014-05-22 21:31
edited on: 2014-05-22 21:41

Will do. EDIT: Posted: https://github.com/ocaml/camlp4/issues/38 [^]

And whoops.
> cd ocaml-4.01.0.tar.gz
in the steps to reproduce should be
> cd ocaml-4.01.0
My mistake.

(0011559)
dim (developer)
2014-05-23 18:43

moved to github

- Issue History
Date Modified Username Field Change
2014-05-22 21:20 labichn New Issue
2014-05-22 21:20 labichn File Added: garrigue.ml
2014-05-22 21:28 dim Assigned To => dim
2014-05-22 21:28 dim Status new => assigned
2014-05-22 21:29 dim Note Added: 0011554
2014-05-22 21:31 labichn Note Added: 0011555
2014-05-22 21:31 labichn Note Edited: 0011555 View Revisions
2014-05-22 21:41 labichn Note Edited: 0011555 View Revisions
2014-05-23 18:43 dim Note Added: 0011559
2014-05-23 18:43 dim Status assigned => closed
2014-05-23 18:43 dim Resolution open => fixed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker