Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005442OCamlCamlp4public2011-12-23 14:592012-06-19 13:08
Assigned Todim 
PlatformallOSOS Version
Product Version3.12.1 
Target VersionFixed in Version3.12.1+dev 
Summary0005442: camlp4: quotation issue with strings
DescriptionThis was reported on 2011-07-11 by Petter Urkedal on caml-list under the subject "Quotation issue with camlp4 printer".

The attached program prints out

    let x = """;;

when compiled with ocamlc and camlp4 version 3.12.0. As you can see,
the string literal lacks an escape character. I haven't tried version
3.12.1, but I didn't find anything about it in the release notes.
Steps To Reproduce    ocamlc.opt -c -I +camlp4 -pp camlp4orf -o quotation_bug.cmo
    ocamlc.opt dynlink.cma -I +camlp4 camlp4lib.cma quotation_bug.cmo
-o quotation_bug.byte
Additional InformationA tentative fix was done in commit 11119, but it breaks findlib (among others) because it double-escapes everything in string constants when preprocessing normal code with "camlp4 pa_o.cmo pr_o.cmo".

It looks like the problem is in the parsing of quotations, not in the printing code.
TagsNo tags attached.
Attached Files? file icon [^] (172 bytes) 2011-12-23 14:59 [Show Content]

- Relationships
related to 0005646resolveddim Camlp4 Printer for escaped string 
related to 0005633resolvedgarrigue takes very long to compile 

-  Notes
dim (developer)
2011-12-23 17:33

Fixed. Commits 11947 and 11948.

The problem was due to the fact that strings are escaped in the camlp4 ast, so they must be escaped again when the ast is meta-expansed, but it was not done.
doligez (administrator)
2011-12-30 13:57

There is a problem with the fix: it breaks type-conv 2.3.0.

To reproduce:
Install type-conv version 2.3.0 (I haven't tried other version) from Jane Street web site.
module Foo = struct end;; module Bar = struct end;;
camlp4o /usr/local/ocaml/3.12/lib/ocaml/site-lib/type-conv/pa_type_conv.cma

With text output, you get: Failure: "Cannot print \"\\\\$:i\" this string contains more than one token"
With AST output, you get a compiler error because both identifiers Foo and Bar got replaced by \$:i

I've narrowed it down to your commit. If I replace "String.escaped" with "safe_string_escaped" at line 474 of boot/, it seems to fix the problem, but I'll let you decide what to do because I don't really understand camlp4.
dim (developer)
2011-12-30 21:02

It is indeed safe_string_escaped that must be used instead of String.escaped.

Fixed by commits 11983 and 11984.

- Issue History
Date Modified Username Field Change
2011-12-23 14:59 doligez New Issue
2011-12-23 14:59 doligez Status new => assigned
2011-12-23 14:59 doligez Assigned To => ertai
2011-12-23 14:59 doligez File Added:
2011-12-23 15:29 doligez Assigned To ertai =>
2011-12-23 15:30 doligez Assigned To => doligez
2011-12-23 15:30 doligez Status assigned => acknowledged
2011-12-23 15:30 doligez Assigned To doligez =>
2011-12-23 17:33 dim Note Added: 0006520
2011-12-23 17:33 dim Assigned To => dim
2011-12-23 17:33 dim Status acknowledged => resolved
2011-12-23 17:33 dim Resolution open => fixed
2011-12-23 17:33 dim Fixed in Version => 3.12.1+dev
2011-12-30 13:57 doligez Note Added: 0006560
2011-12-30 13:57 doligez Status resolved => feedback
2011-12-30 13:57 doligez Resolution fixed => reopened
2011-12-30 13:58 doligez Status feedback => acknowledged
2011-12-30 21:02 dim Note Added: 0006573
2011-12-30 21:02 dim Status acknowledged => resolved
2011-12-30 21:02 dim Resolution reopened => fixed
2012-06-12 17:23 dim Relationship added related to 0005646
2012-06-19 13:08 garrigue Relationship added related to 0005633

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker