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

Can't define types with True or False #4705

Closed
vicuna opened this issue Jan 31, 2009 · 0 comments
Closed

Can't define types with True or False #4705

vicuna opened this issue Jan 31, 2009 · 0 comments

Comments

@vicuna
Copy link

vicuna commented Jan 31, 2009

Original bug ID: 4705
Reporter: @mjambon
Assigned to: @xclerc
Status: closed (set by @xavierleroy on 2012-09-25T18:06:17Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.11.0
Fixed in version: 3.12.1+dev
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues

Bug description

Quotations in the revised syntax do not handle True or False correctly in type definitions. It is very hard to guess since the type definition is processed and compiled without errors. The problems only occur when using the type in question.

Affected versions: 3.10.2, 3.11.0 with camlp4orf
Old Camlp4 3.09.2 works fine on that case.

$ ocamlc -c -pp camlp4orf -I +camlp4 pa_foo.ml
$ ocamlc -c -pp 'camlp4o -parser pa_foo.cmo' foo.ml
File "foo.ml", line 10, characters 1-7:
Error: This expression has type [> False ] but is here used with type foo The second variant type does not allow tag(s) False

(*
This is pa_foo.ml

ocamlc -c -pp camlp4orf -I +camlp4 pa_foo.ml
*)

open Camlp4.PreCast
open Syntax

EXTEND Gram
GLOBAL: str_item;
str_item: [
[ "FOO" -> <:str_item< type foo = [ = `False ] >> ]
];
END
;;
(*********************************************************)

(*
This is foo.ml

camlp4o -parser pa_foo.cmo -printer o foo.ml
ocamlc -c -pp 'camlp4o -parser pa_foo.cmo' foo.ml
*)

FOO ;;

(`False : foo)

(*********************************************************)

Pretty-printing goes well:

$ camlp4o -parser pa_foo.cmo -printer o foo.ml
(*
This is foo.ml

camlp4o -parser pa_foo.cmo -printer o foo.ml
ocamlc -c -pp 'camlp4o -parser pa_foo.cmo' foo.ml
*)
type foo = [ | `False ]

let _ = (`False : foo)


So one first workaround is to preprocess files with 'camlp4o -printer o ...'.
Another workaround is to avoid using True or False.
A third workaround is to use quotations in the classic syntax.

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