Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004705OCamlCamlp4public2009-01-31 01:312012-09-25 20:06
ReporterMartin Jambon 
Assigned Toxclerc 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version3.11.0 
Target VersionFixed in Version3.12.1+dev 
Summary0004705: Can't define types with `True or `False
DescriptionQuotations 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.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2009-01-31 01:31 Martin Jambon New Issue
2009-03-28 17:18 xleroy Status new => assigned
2009-03-28 17:18 xleroy Assigned To => ertai
2011-09-05 15:38 xclerc Assigned To ertai => xclerc
2011-09-05 15:39 xclerc Status assigned => resolved
2011-09-05 15:39 xclerc Fixed in Version => 3.12.1+dev
2011-09-05 15:39 xclerc Resolution open => fixed
2012-09-25 20:06 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker