Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006221OCamlfor Camlp4 use 23:552015-12-11 19:27
Assigned Toyallop 
PlatformOSOS Version
Product Version3.12.1 
Target VersionlaterFixed in Version 
Summary0006221: Spurious (?) camlp4 error
DescriptionBy looking at: [^]

there is a line:

     <:ctyp< t : t >> ....... Field declaration
                        ........ TyCol of Loc.t and ctyp and ctyp

so it seems that it should also be somehow posible to get a quote for "field declaration", i.e.:


However, if I try that, I get an error:

  While expanding quotation "ctyp" in a position of "expr":
    Parse error: "->" expected after [ctyp level star] (in [ctyp]

That might not be the expected camlp4 behavior.
Instead, it should expand that quotation to something like:

  Ast.TyCol (_loc,
             (Ast.TyId (_loc, (Ast.IdLid (_loc, "foo1")))),
             (Ast.TyId (_loc, (Ast.IdLid (_loc, "bar1")))))
Attached Filespatch file icon field_parsing.patch [^] (813 bytes) 2013-11-04 10:19 [Show Content]

- Relationships

-  Notes
hongboz (developer)
2013-11-03 01:29

I think the documentation may be incorrect. where do you expect 'foo1:bar' appear?
If it appears in record, then it should be recognized as type representation, not type expression.
kosik (reporter)
2013-11-03 09:36


This suggestion:

  <:ctyp< t : t >>

I have found here: [^]

It appears on the line that contains


yallop (developer)
2013-11-04 10:19

It looks like camlp4 is committing to parsing x:y as a labeled argument rather than a record field as soon as it's seen the colon. I've attached a patch that changes the parser so that it waits until it's seen the function arrow before committing.

   $ cat
   let _ = <:ctyp< x:y -> int >>

   $ cat
   let _ = <:ctyp< x:y >>

Without the patch:

   $ camlp4of
   Ast.TyArr (_loc,
     Ast.TyLab (_loc, "x", Ast.TyId (_loc, Ast.IdLid (_loc, "y"))),
     Ast.TyId (_loc, Ast.IdLid (_loc, "int")))

   $ camlp4of
   File "", line 1, characters 20-21:
   While expanding quotation "ctyp" in a position of "expr":
     Parse error: [ctyp level star] expected after [lident_colon] (in [ctyp])

With the patch:

   $ camlp4of
   Ast.TyArr (_loc,
     (Ast.TyLab (_loc, "x", (Ast.TyId (_loc, (Ast.IdLid (_loc, "y")))))),
     (Ast.TyId (_loc, (Ast.IdLid (_loc, "int")))))

   $ camlp4of
   Ast.TyCol (_loc, (Ast.TyId (_loc, (Ast.IdLid (_loc, "x")))),
     (Ast.TyId (_loc, (Ast.IdLid (_loc, "y")))))
yallop (developer)
2014-05-30 15:06

Fixed in Camlp4 trunk: [^]

- Issue History
Date Modified Username Field Change
2013-11-02 23:55 kosik New Issue
2013-11-03 01:29 hongboz Note Added: 0010563
2013-11-03 09:36 kosik Note Added: 0010564
2013-11-04 10:19 yallop Note Added: 0010568
2013-11-04 10:19 yallop File Added: field_parsing.patch
2014-02-19 16:38 doligez Tag Attached: patch
2014-05-25 20:00 doligez Target Version => later
2014-05-30 14:00 shinwell Assigned To => yallop
2014-05-30 14:00 shinwell Status new => acknowledged
2014-05-30 15:06 yallop Note Added: 0011604
2014-05-30 15:06 yallop Status acknowledged => resolved
2014-05-30 15:06 yallop Resolution open => fixed
2015-12-11 19:27 xleroy Status resolved => closed
2016-02-08 12:49 doligez Category Camlp4 => for Camlp4 use [^]
2016-02-08 12:50 doligez Category for Camlp4 use [^] => for Camlp4 use [^]

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker