Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005705OCamlCamlp4public2012-07-29 17:452014-09-04 00:25
Reportermottl 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusconfirmedResolutionopen 
PlatformOSOS Version
Product Version4.00.0 
Target VersionundecidedFixed in Version 
Summary0005705: Camlp4 accepts bad syntax and may also bomb on it
DescriptionThe following file "x.ml" will lead to a syntax error with "ocaml x.ml":

  let f x : type a. a = ()

But "camlp4o x.ml" will accept and print the human-readable format.

By contrast, "ocamldep -pp camlp4o x.ml" will bomb:

  Assertion failed, file "camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml", line 284, char 8
  Preprocessing error on file x.ml
  x.cmo :
  x.cmx :
  EXIT STATUS 2
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0007838)
hongboz (developer)
2012-07-31 05:22

It's weird (-verbose) will change the semantics of camlp4 parser
camlp4>camlp4o -filter lift -str 'let f x : type a . a = () '
let loc = Loc.ghost
in
  Ast.StVal (loc, Ast.ReNil,
    (Ast.BiEq (loc, (Ast.PaId (loc, (Ast.IdLid (loc, "f")))),
       (Ast.ExFun (loc,
          (Ast.McArr (loc, (Ast.PaId (loc, (Ast.IdLid (loc, "x")))),
             (Ast.ExNil loc),
             (Ast.ExTyc (loc, (Ast.ExId (loc, (Ast.IdUid (loc, "()")))),
                (Ast.TyTypePol (loc,
                   (Ast.TyId (loc, (Ast.IdLid (loc, "a")))),
                   (Ast.TyId (loc, (Ast.IdLid (loc, "a")))))))))))))))


camlp4>camlp4o -verbose -filter lift -str 'let f x : type a . a = () '

----------------------------------
Parse error in entry [ctyp], rule:
  [ TRY [ a_LIDENT; ":" ]; ctyp LEVEL "star"; "->"; SELF ]
----------------------------------

let loc = Loc.ghost
in
  Ast.StVal (loc, Ast.ReNil,
    (Ast.BiEq (loc, (Ast.PaId (loc, (Ast.IdLid (loc, "f")))),
       (Ast.ExFun (loc,
          (Ast.McArr (loc, (Ast.PaId (loc, (Ast.IdLid (loc, "x")))),
             (Ast.ExNil loc),
             (Ast.ExTyc (loc, (Ast.ExId (loc, (Ast.IdUid (loc, "()")))),
                (Ast.TyTypePol (loc,
                   (Ast.TyId (loc, (Ast.IdLid (loc, "a")))),
                   (Ast.TyId (loc, (Ast.IdLid (loc, "a")))))))))))))))
(0008148)
hongboz (developer)
2012-09-24 00:12

the problem comes from the entry cvalue_binding
 cvalue_binding:
           | ":"; "type"; t1 = unquoted_typevars; "." ; t2 = ctyp ; "="; e = expr ->
              let u = Ast.TyTypePol _loc t1 t2 in
              <:expr< ($e : $u) >>
The parser goes from binding -> fun_binding -> cvalue_binding.
Would it be safe to delete this rule?
cvalue_binding is invoked in another place
 | o = value_val_opt_override; mf = opt_mutable; lab = label; e = cvalue_binding ->
      <:class_str_item< value $override:o $mutable:mf $lab = $e >>

- Issue History
Date Modified Username Field Change
2012-07-29 17:45 mottl New Issue
2012-07-31 05:22 hongboz Note Added: 0007838
2012-07-31 13:25 doligez Status new => confirmed
2012-07-31 13:25 doligez Target Version => 4.00.1+dev
2012-07-31 16:55 doligez Severity major => minor
2012-09-21 14:55 doligez Target Version 4.00.1+dev => 4.00.2+dev
2012-09-24 00:12 hongboz Note Added: 0008148
2013-07-11 16:24 doligez Target Version 4.00.2+dev => 4.02.0+dev
2013-07-12 18:15 doligez Target Version 4.02.0+dev => 4.01.1+dev
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-08-21 11:24 doligez Target Version 4.02.0+dev => 4.02.1+dev
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker