Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocessor issues with polymorphic variants #6440

Closed
vicuna opened this issue May 22, 2014 · 3 comments
Closed

Preprocessor issues with polymorphic variants #6440

vicuna opened this issue May 22, 2014 · 3 comments

Comments

@vicuna
Copy link

vicuna commented May 22, 2014

Original bug ID: 6440
Reporter: labichn
Assigned to: @diml
Status: closed (set by @diml on 2014-05-23T16:43:58Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: x86_64
OS: GNU/Linux
OS Version: 3.14.4-1-ARCH
Version: 4.01.0
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Monitored by: @gasche

Bug description

There 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 information

It 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).

File attachments

@vicuna
Copy link
Author

vicuna commented May 22, 2014

Comment author: @diml

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

@vicuna
Copy link
Author

vicuna commented May 22, 2014

Comment author: labichn

Will do. EDIT: Posted: camlp4/camlp4#38

And whoops.

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

@vicuna
Copy link
Author

vicuna commented May 23, 2014

Comment author: @diml

moved to github

@vicuna vicuna closed this as completed May 23, 2014
@vicuna vicuna added the camlp4 label Mar 14, 2019
@vicuna vicuna assigned ghost Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant