Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Aug 1, 2018
1 parent dadb712 commit b13d22a
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 36 deletions.
14 changes: 8 additions & 6 deletions parsing/ast_mapper.ml
Expand Up @@ -925,19 +925,21 @@ let apply_lazy ~source ~target mapper =
else fail ()

let drop_ppx_context_str ~restore = function
| {pstr_desc = Pstr_attribute({attr_name = {Location.txt = "ocaml.ppx.context"};
attr_payload = a;
attr_loc = _})}
| {pstr_desc = Pstr_attribute
{attr_name = {Location.txt = "ocaml.ppx.context"};
attr_payload = a;
attr_loc = _}}
:: items ->
if restore then
PpxContext.restore (PpxContext.get_fields a);
items
| items -> items

let drop_ppx_context_sig ~restore = function
| {psig_desc = Psig_attribute({attr_name = {Location.txt = "ocaml.ppx.context"};
attr_payload = a;
attr_loc = _})}
| {psig_desc = Psig_attribute
{attr_name = {Location.txt = "ocaml.ppx.context"};
attr_payload = a;
attr_loc = _}}
:: items ->
if restore then
PpxContext.restore (PpxContext.get_fields a);
Expand Down
38 changes: 22 additions & 16 deletions parsing/builtin_attributes.ml
Expand Up @@ -151,17 +151,24 @@ let warning_attribute ?(ppwarning = true) =
(txt, "A single string literal is expected"))
in
function
| {attr_name = {txt = ("ocaml.warning"|"warning") as txt; _}; attr_payload; attr_loc} ->
| {attr_name = {txt = ("ocaml.warning"|"warning") as txt; _};
attr_loc;
attr_payload;
} ->
process attr_loc txt false attr_payload
| {attr_name = {txt = ("ocaml.warnerror"|"warnerror") as txt; _}; attr_payload; attr_loc} ->
| {attr_name = {txt = ("ocaml.warnerror"|"warnerror") as txt; _};
attr_loc;
attr_payload
} ->
process attr_loc txt true attr_payload
| {attr_name = {txt="ocaml.ppwarning"|"ppwarning"; _};
attr_loc = _;
attr_payload =
PStr [
{ pstr_desc=Pstr_eval({pexp_desc=Pexp_constant (Pconst_string (s, _))},_);
pstr_loc }
];
attr_loc = _
{ pstr_desc=
Pstr_eval({pexp_desc=Pexp_constant (Pconst_string (s, _))},_);
pstr_loc }
];
} when ppwarning ->
Location.prerr_warning pstr_loc (Warnings.Preprocessor s)
| _ ->
Expand All @@ -181,24 +188,23 @@ let warning_scope ?ppwarning attrs f =

let warn_on_literal_pattern =
List.exists
(function
| {attr_name = {txt="ocaml.warn_on_literal_pattern"|"warn_on_literal_pattern"; _}; _}
-> true
| _ -> false
(fun a -> match a.attr_name.txt with
| "ocaml.warn_on_literal_pattern"|"warn_on_literal_pattern" -> true
| _ -> false
)

let explicit_arity =
List.exists
(function
| {attr_name = {txt="ocaml.explicit_arity"|"explicit_arity"; _}; _} -> true
| _ -> false
(fun a -> match a.attr_name.txt with
| "ocaml.explicit_arity"|"explicit_arity" -> true
| _ -> false
)

let immediate =
List.exists
(function
| {attr_name = {txt="ocaml.immediate"|"immediate"; _}; _} -> true
| _ -> false
(fun a -> match a.attr_name.txt with
| "ocaml.immediate"|"immediate" -> true
| _ -> false
)

(* The "ocaml.boxed (default)" and "ocaml.unboxed (default)"
Expand Down
4 changes: 2 additions & 2 deletions parsing/parsetree.mli
Expand Up @@ -42,8 +42,8 @@ type constant =
type attribute = {
attr_name : string loc;
attr_payload : payload;
attr_loc : Location.t
}
attr_loc : Location.t;
}
(* [@id ARG]
[@@id ARG]
Expand Down
3 changes: 2 additions & 1 deletion testsuite/tests/parsetree/test.ml
Expand Up @@ -21,7 +21,8 @@ let remove_locs =
attributes =
(fun mapper attrs ->
let attrs = default_mapper.attributes mapper attrs in
List.filter (fun {Parsetree.attr_name;_} -> attr_name.Location.txt <> "#punning#")
List.filter (fun a ->
a.Parsetree.attr_name.Location.txt <> "#punning#")
attrs (* this is to accomodate a LexiFi custom extension *)
)
}
Expand Down
8 changes: 6 additions & 2 deletions toplevel/topdirs.ml
Expand Up @@ -480,9 +480,13 @@ let trim_signature = function
(List.map
(function
Sig_module (id, md, rs) ->
let attribute =
Ast_helper.Attr.mk
(Location.mknoloc "...")
(Parsetree.PStr [])
in
Sig_module (id, {md with md_attributes =
(Ast_helper.Attr.mk (Location.mknoloc "...") (Parsetree.PStr []))
:: md.md_attributes},
attribute :: md.md_attributes},
rs)
(*| Sig_modtype (id, Modtype_manifest mty) ->
Sig_modtype (id, Modtype_manifest (trim_modtype mty))*)
Expand Down
3 changes: 2 additions & 1 deletion typing/parmatch.ml
Expand Up @@ -2453,7 +2453,8 @@ let all_rhs_idents exp =
and perform "indirect check for them" *)
let is_unpack exp =
List.exists
(fun attr -> attr.Parsetree.attr_name.txt = "#modulepat") exp.exp_attributes
(fun attr -> attr.Parsetree.attr_name.txt = "#modulepat")
exp.exp_attributes

let leave_expression exp =
if is_unpack exp then begin match exp.exp_desc with
Expand Down
6 changes: 3 additions & 3 deletions typing/predef.ml
Expand Up @@ -199,9 +199,9 @@ let common_initial_env add_type add_extension empty_env =
ext_ret_type = None;
ext_private = Asttypes.Public;
ext_loc = Location.none;
ext_attributes = [{Parsetree.attr_name = Location.mknoloc "ocaml.warn_on_literal_pattern";
attr_payload = Parsetree.PStr [];
attr_loc = Location.none } ] }
ext_attributes = [Ast_helper.Attr.mk
(Location.mknoloc "ocaml.warn_on_literal_pattern")
(Parsetree.PStr [])] }
in
add_extension ident_match_failure
[newgenty (Ttuple[type_string; type_int; type_int])] (
Expand Down
5 changes: 3 additions & 2 deletions typing/printtyp.ml
Expand Up @@ -1610,8 +1610,9 @@ and trees_of_sigitem = function
[tree_of_extension_constructor id ext es]
| Sig_module(id, md, rs) ->
let ellipsis =
List.exists (function Parsetree.{attr_name = {txt="..."}; attr_payload = PStr []} -> true
| _ -> false)
List.exists (function
| Parsetree.{attr_name = {txt="..."}; attr_payload = PStr []} -> true
| _ -> false)
md.md_attributes in
[tree_of_module id md.md_type rs ~ellipsis]
| Sig_modtype(id, decl) ->
Expand Down
6 changes: 4 additions & 2 deletions typing/typecore.ml
Expand Up @@ -1977,7 +1977,8 @@ let create_package_type loc env (p, l) =
let open Ast_helper in
List.fold_left
(fun sexp (name, loc) ->
Exp.letmodule ~loc:sexp.pexp_loc ~attrs:[Attr.mk (mknoloc "#modulepat") (PStr [])]
Exp.letmodule ~loc:sexp.pexp_loc
~attrs:[Attr.mk (mknoloc "#modulepat") (PStr [])]
name
(Mod.unpack ~loc
(Exp.ident ~loc:name.loc (mkloc (Longident.Lident name.txt)
Expand Down Expand Up @@ -2334,7 +2335,8 @@ and type_expect_
in
let pat = Pat.var ~loc:sloc (mknoloc "*opt*") in
let body =
Exp.let_ ~loc Nonrecursive ~attrs:[Attr.mk (mknoloc "#default") (PStr [])]
Exp.let_ ~loc Nonrecursive
~attrs:[Attr.mk (mknoloc "#default") (PStr [])]
[Vb.mk spat smatch] sbody
in
type_function ?in_function loc sexp.pexp_attributes env
Expand Down
2 changes: 1 addition & 1 deletion typing/untypeast.ml
Expand Up @@ -131,7 +131,7 @@ let attribute sub a = {
attr_payload = a.attr_payload;
attr_loc = a.attr_loc
}

let attributes sub l = List.map (sub.attribute sub) l

let structure sub str =
Expand Down

0 comments on commit b13d22a

Please sign in to comment.