Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005374OCamlCamlp4public2011-10-12 03:092012-09-25 20:07
Reporterfuruse 
Assigned Toxclerc 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version3.12.1 
Target VersionFixed in Version3.12.1+dev 
Summary0005374: camlp4 creates wrong location for type definitions
DescriptionCamlp4 creates an AST with a wrong location information of the following simple type definition:

----------- p4bug.ml
type t
-----------

ocamlc -pp camlp4o -c p4bug.ml

The type declaration is at line 2, characters 0--1 , which is just after the real location, where nothing exists. It should be line 1, characters 0-5 or something around it.

(This issue is one of the causes of wrong location information in CamlSpotter.)
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0006160)
furuse (reporter)
2011-10-12 08:55

The following patch seems to fix the issue, but not sure. Please review:


diff -r 2aa557dc10ec -r 6c3e3f09464f camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml
--- a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml Sat Oct 08 15:55:45 2011 +0900
+++ b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml Wed Oct 12 15:52:35 2011 +0900
@@ -346,7 +346,7 @@
         mktype loc tl cl Ptype_abstract (mkprivate' pflag) m ]
   ;
 
- value type_decl tl cl t = type_decl tl cl (loc_of_ctyp t) None False t;
+ value type_decl tl cl t loc = type_decl tl cl loc None False t;
 
   value mkvalue_desc t p = {pval_type = ctyp t; pval_prim = p};
 
@@ -835,7 +835,7 @@
     match x with
     [ <:ctyp< $x$ and $y$ >> ->
          mktype_decl x (mktype_decl y acc)
- | Ast.TyDcl _ c tl td cl ->
+ | Ast.TyDcl _loc c tl td cl ->
         let cl =
           List.map
             (fun (t1, t2) ->
@@ -843,7 +843,7 @@
               (ctyp t1, ctyp t2, mkloc loc))
             cl
         in
- [(c, type_decl (List.fold_right type_parameters tl []) cl td) :: acc]
+ [(c, type_decl (List.fold_right type_parameters tl []) cl td _loc) :: acc]
     | _ -> assert False ]
   and module_type =
     fun
diff -r 2aa557dc10ec -r 6c3e3f09464f camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml
--- a/camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml Sat Oct 08 15:55:45 2011 +0900
+++ b/camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml Wed Oct 12 15:52:35 2011 +0900
@@ -1004,7 +1004,7 @@
     ;
     opt_eq_ctyp:
       [ [ "="; tk = type_kind -> tk
- | -> <:ctyp<>> ] ]
+ | -> let _loc = Loc.ghost in <:ctyp<>> ] ]
     ;
     type_kind:
       [ [ t = ctyp -> t ] ]
(0006422)
dim (developer)
2011-12-20 18:45

Patch reviewed and applied. Thanks.

Commits 11901 and 11903.

- Issue History
Date Modified Username Field Change
2011-10-12 03:09 furuse New Issue
2011-10-12 03:09 furuse Status new => assigned
2011-10-12 03:09 furuse Assigned To => ertai
2011-10-12 08:55 furuse Note Added: 0006160
2011-10-26 08:31 ertai Assigned To ertai => xclerc
2011-12-20 18:45 dim Note Added: 0006422
2011-12-20 18:46 dim Status assigned => resolved
2011-12-20 18:46 dim Resolution open => fixed
2011-12-20 18:46 dim Fixed in Version => 3.12.1+dev
2012-09-25 20:07 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker