From 2a158e9a105726a61c19208a9437a420f3c6722f Mon Sep 17 00:00:00 2001 From: Patrick Ferris Date: Wed, 11 Dec 2024 09:53:13 +0000 Subject: [PATCH] Change Location.none Location.none has been changed to match the compiler's Location.none as of OCaml 4.08. This has been stable for some time. We also provide a Location.is_none which checks if a location is equal to Location.none for all versions of the compiler we currently support (i.e. >= 4.04). The decision to change Location.none has been made to enable the code to be simplified if we decide to change the lower bound of ppxlib to 4.08 in the future. Location.is_none has been used to fix loc_of_attribute which would sometimes miss attributes with none locations (like compiler inserted ocaml.doc attributes). Signed-off-by: Patrick Ferris --- src/common.ml | 4 +- src/location.ml | 11 +- src/location.mli | 6 + test/location/attributes/dune | 7 + test/location/attributes/pp.ml | 18 +++ test/location/attributes/print_attr_loc.t | 15 ++ test/metaquot/test.ml | 180 +++++++++++----------- test/type_is_recursive/test.ml | 4 +- 8 files changed, 150 insertions(+), 95 deletions(-) create mode 100644 test/location/attributes/dune create mode 100644 test/location/attributes/pp.ml create mode 100644 test/location/attributes/print_attr_loc.t diff --git a/src/common.ml b/src/common.ml index d0e9dbd0e..9841c7047 100644 --- a/src/common.ml +++ b/src/common.ml @@ -148,7 +148,7 @@ let loc_of_attribute { attr_name; attr_payload; attr_loc = _ } = from older asts. *) (* "ocaml.doc" attributes are generated with [Location.none], which is not helpful for error messages. *) - if Poly.( = ) attr_name.loc Location.none then + if Location.is_none attr_name.loc then loc_of_name_and_payload attr_name attr_payload else { @@ -157,7 +157,7 @@ let loc_of_attribute { attr_name; attr_payload; attr_loc = _ } = } let loc_of_extension (name, payload) = - if Poly.( = ) name.loc Location.none then loc_of_name_and_payload name payload + if Location.is_none name.loc then loc_of_name_and_payload name payload else { name.loc with loc_end = (loc_of_name_and_payload name payload).loc_end } diff --git a/src/location.ml b/src/location.ml index 54daa6397..908e8dfc1 100644 --- a/src/location.ml +++ b/src/location.ml @@ -8,7 +8,7 @@ type t = location = { } let in_file name = - let loc = { pos_fname = name; pos_lnum = 1; pos_bol = 0; pos_cnum = -1 } in + let loc = { pos_fname = name; pos_lnum = 0; pos_bol = 0; pos_cnum = -1 } in { loc_start = loc; loc_end = loc; loc_ghost = true } let set_filename loc fn = @@ -18,6 +18,15 @@ let set_filename loc fn = let none = in_file "_none_" +(* Can be removed once ppxlib only supports 4.08.0+ *) +let none_4_07_and_less = + let loc = + { pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; pos_cnum = -1 } + in + { loc_start = loc; loc_end = loc; loc_ghost = true } + +let is_none v = Poly.( = ) v none || Poly.( = ) v none_4_07_and_less + let init lexbuf fname = let open Lexing in lexbuf.lex_curr_p <- diff --git a/src/location.mli b/src/location.mli index a6f4f6b54..a45e68f26 100644 --- a/src/location.mli +++ b/src/location.mli @@ -23,6 +23,12 @@ val set_filename : t -> string -> t val none : t (** An arbitrary value of type [t]; describes an empty ghost range. *) +val is_none : t -> bool +(** Checks whether a given location is equal to [none]. + + Note that this function returns [true] for none locations from all supported + compiler versions. *) + val init : Lexing.lexbuf -> string -> unit (** Set the file name and line number of the [lexbuf] to be the start of the named file. *) diff --git a/test/location/attributes/dune b/test/location/attributes/dune new file mode 100644 index 000000000..9dd7e34ed --- /dev/null +++ b/test/location/attributes/dune @@ -0,0 +1,7 @@ +(executable + (name pp) + (libraries ppxlib)) + +(cram + (applies_to print_attr_loc) + (deps pp.exe)) diff --git a/test/location/attributes/pp.ml b/test/location/attributes/pp.ml new file mode 100644 index 000000000..65cb51025 --- /dev/null +++ b/test/location/attributes/pp.ml @@ -0,0 +1,18 @@ +open Ppxlib + +let pp_attr str = + let iter = + object + inherit Ast_traverse.iter as super + + method! attribute v = + let loc = loc_of_attribute v in + Format.printf "%a %s" Location.print loc v.attr_name.txt; + super#attribute v + end + in + iter#structure str; + str + +let () = Driver.register_transformation ~impl:pp_attr "print-attributes" +let () = Ppxlib.Driver.standalone () diff --git a/test/location/attributes/print_attr_loc.t b/test/location/attributes/print_attr_loc.t new file mode 100644 index 000000000..fdf31a93a --- /dev/null +++ b/test/location/attributes/print_attr_loc.t @@ -0,0 +1,15 @@ +The compiler inserts documentation comments with their location set to +`Location.none`. The value for `Location.none` has changed in the compiler (at +4.08.0). We provide a function, `loc_of_attribute` to handle deriving better location +errors for attributes with a none location. + + $ cat > test.ml << EOF + > let v = 1 + > (** A documentation comment! *) + > EOF + +We run an identity driver that prints the locations of attributes. + + $ ./pp.exe --impl test.ml -o ignore.ml + File "test.ml", line 2, characters 0-31: ocaml.doc + diff --git a/test/metaquot/test.ml b/test/metaquot/test.ml index 52a2b2666..0e1001503 100644 --- a/test/metaquot/test.ml +++ b/test/metaquot/test.ml @@ -2,9 +2,9 @@ let loc = Ppxlib.Location.none [%%expect{| val loc : Warnings.loc = {Ppxlib.Location.loc_start = - {Lexing.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; pos_cnum = -1}; + {Lexing.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Lexing.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; pos_cnum = -1}; + {Lexing.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true} |}] @@ -18,19 +18,19 @@ let _ = [%expr ()] ({Ppxlib_ast.Ast.txt = Ppxlib_ast.Ast.Lident "()"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}, None); pexp_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; pexp_loc_stack = []; pexp_attributes = []} @@ -44,19 +44,19 @@ let _ = [%pat? ()] ({Ppxlib_ast.Ast.txt = Ppxlib_ast.Ast.Lident "()"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}, None); ppat_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; ppat_loc_stack = []; ppat_attributes = []} @@ -70,19 +70,19 @@ let _ = [%type: unit] ({Ppxlib_ast.Ast.txt = Ppxlib_ast.Ast.Lident "unit"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}, []); ptyp_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; ptyp_loc_stack = []; ptyp_attributes = []} @@ -97,10 +97,10 @@ let _ = [%stri let _ = ()] {Ppxlib_ast.Ast.ppat_desc = Ppxlib_ast.Ast.Ppat_any; ppat_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; ppat_loc_stack = []; ppat_attributes = []}; @@ -110,37 +110,37 @@ let _ = [%stri let _ = ()] ({Ppxlib_ast.Ast.txt = Ppxlib_ast.Ast.Lident "()"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}, None); pexp_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; pexp_loc_stack = []; pexp_attributes = []}; pvb_attributes = []; pvb_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}]); pstr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}} |}] @@ -156,36 +156,36 @@ let _ = [%sigi: include S] {Ppxlib_ast.Ast.txt = Ppxlib_ast.Ast.Lident "S"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; pmty_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; pmty_attributes = []}; pincl_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; pincl_attributes = []}; psig_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}} |}] @@ -199,10 +199,10 @@ let _ = [%str let _ = ()] {Ppxlib_ast.Ast.ppat_desc = Ppxlib_ast.Ast.Ppat_any; ppat_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; ppat_loc_stack = []; ppat_attributes = []}; @@ -212,37 +212,37 @@ let _ = [%str let _ = ()] ({Ppxlib_ast.Ast.txt = Ppxlib_ast.Ast.Lident "()"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}, None); pexp_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; pexp_loc_stack = []; pexp_attributes = []}; pvb_attributes = []; pvb_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}]); pstr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}] |}] @@ -258,36 +258,36 @@ let _ = [%sig: include S] {Ppxlib_ast.Ast.txt = Ppxlib_ast.Ast.Lident "S"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; pmty_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; pmty_attributes = []}; pincl_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}; pincl_attributes = []}; psig_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}] |}] @@ -303,38 +303,38 @@ let _ = {Ppxlib_ast.Ast.txt = "attr1"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; attr_payload = Ppxlib_ast.Ast.PStr []; attr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; {Ppxlib_ast.Ast.attr_name = {Ppxlib_ast.Ast.txt = "attr2"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; attr_payload = Ppxlib_ast.Ast.PStr []; attr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}] |}] @@ -348,38 +348,38 @@ let _ = {Ppxlib_ast.Ast.txt = "attr1"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; attr_payload = Ppxlib_ast.Ast.PStr []; attr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; {Ppxlib_ast.Ast.attr_name = {Ppxlib_ast.Ast.txt = "attr2"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; attr_payload = Ppxlib_ast.Ast.PStr []; attr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}] |}] @@ -393,38 +393,38 @@ let _ = {Ppxlib_ast.Ast.txt = "attr1"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; attr_payload = Ppxlib_ast.Ast.PStr []; attr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; {Ppxlib_ast.Ast.attr_name = {Ppxlib_ast.Ast.txt = "attr2"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; attr_payload = Ppxlib_ast.Ast.PStr []; attr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}] |}] @@ -443,38 +443,38 @@ let _ = {Ppxlib_ast.Ast.txt = "attr1"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; attr_payload = Ppxlib_ast.Ast.PStr []; attr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; {Ppxlib_ast.Ast.attr_name = {Ppxlib_ast.Ast.txt = "attr2"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; attr_payload = Ppxlib_ast.Ast.PStr []; attr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}] |}] @@ -493,38 +493,38 @@ let _ = {Ppxlib_ast.Ast.txt = "attr1"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; attr_payload = Ppxlib_ast.Ast.PStr []; attr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; {Ppxlib_ast.Ast.attr_name = {Ppxlib_ast.Ast.txt = "attr2"; loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}; attr_payload = Ppxlib_ast.Ast.PStr []; attr_loc = {Ppxlib_ast.Ast.loc_start = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; + {Ppxlib_ast.Ast.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true}}] |}] diff --git a/test/type_is_recursive/test.ml b/test/type_is_recursive/test.ml index 8f24b81f0..ae7a75e1f 100644 --- a/test/type_is_recursive/test.ml +++ b/test/type_is_recursive/test.ml @@ -14,9 +14,9 @@ let loc = Location.none [%%expect{| val loc : location = {Ppxlib.Location.loc_start = - {Lexing.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; pos_cnum = -1}; + {Lexing.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_end = - {Lexing.pos_fname = "_none_"; pos_lnum = 1; pos_bol = 0; pos_cnum = -1}; + {Lexing.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1}; loc_ghost = true} |}]