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

all uppercase polymorphic variants cannot be parsed when camlp4.macro is enabled #4732

vicuna opened this issue Feb 26, 2009 · 3 comments


None yet
1 participant
Copy link

commented Feb 26, 2009

Original bug ID: 4732
Reporter: zack
Assigned to: ertai
Status: closed (set by @xavierleroy on 2012-09-25T18:06:17Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.11.0
Fixed in version: 3.12.1+dev
Category: -for Camlp4 use
Monitored by: "Richard Jones" @Chris00 zack

Bug description

Looks like there is a conflict between cpp-like macros (as enabled by the camlp4.macro package) and all uppercase polymorphic variants.

I've set severity major, because this bug currently inhibit using camlp4 with libraries which require all uppercase macros in their API. A notable example is lablgtk2, which uses stuff like IN, OUT, ...

Here is how to reproduce (using findlib):

$ ledit ocaml
Objective Caml version 3.11.0

#use "topfind";;

Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads


/usr/lib/ocaml/3.11.0/dynlink.cma: loaded
/usr/lib/ocaml/3.11.0/camlp4: added to search path
/usr/lib/ocaml/3.11.0/camlp4/camlp4o.cma: loaded
Camlp4 Parsing version 3.11.0

`IN;; (* plain camlp4, works fine *)

  • : [> IN ] = IN

#require "camlp4.macro";;

/usr/lib/ocaml/3.11.0/camlp4/Camlp4Parsers/Camlp4MacroParser.cmo: loaded

`IN;; (* no longer works *)

Error: Parse error: [a_ident] expected after "`" (in [expr])

`In;; (* if we renounce to all uppercase, it works again :-/ *)

  • : [> In ] = In


This comment has been minimized.

Copy link

commented Feb 27, 2009

Comment author: zack

Actually, the bug title is misleading. It is not the case that all uppercase polymorphic variants cannot be parser, but only `IN (which is possibly a keyword for the new camlp4).

Nevertheless the problem stands, partly because IN is used by libraries out there (e.g. lablgtk2), partly because the bug appears only when you use the camlp4.macro package, which makes harder for library published to know they should refrain from using IN.


This comment has been minimized.

Copy link

commented Mar 1, 2009

Comment author: @Chris00

The "IN" comes from local macros "DEFINE ... IN ...". For now, you may want to use Delimited overloading macros which does not have that problem.


This comment has been minimized.

Copy link

commented Dec 17, 2010

Comment author: Richard Jones

Also `END cannot be parsed.

This is annoying in lablgtk2 programs where `END is used as a packing hint.

You can work around the bug like this:

Printf.printf "%d\n" (Obj.magic `END : int) ;;


then in the program replace this:

hbox#pack ~from:`END

with this:

let from = Obj.magic 3448763 in
hbox#pack ~from

@vicuna vicuna closed this Sep 25, 2012

@vicuna vicuna added the camlp4 label 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
You can’t perform that action at this time.