ppxlib
ppxlib copied to clipboard
Same attribute can be matched by multiple ppxes.
The following:
let () =
let make_rule name =
Context_free.Rule.attr_str_type_decl_expect
(Attribute.declare
name
Type_declaration
Ast_pattern.(pstr nil)
(fun x -> x))
(fun ~ctxt:_ _ _ _ ->
let loc = Location.none in
[ Ast_builder.Default.(pstr_eval ~loc (estring ~loc ("I am " ^ name)) []) ])
in
Driver.register_transformation
"foobar"
~rules:[ make_rule "bar.foo"; make_rule "qux.foo" ];
Would allow:
type t = int [@@bar.foo]
"I am bar.foo"
[@@@end]
type u = int [@@qux.foo]
"I am qux.foo"
[@@@end]
type v = int [@@foo]
"I am bar.foo";;
"I am qux.foo"
[@@@end]
It seems that ppxlib doesn't protect against an attribute from being matched by two (or more) different Attribute.t declarations in instances when the name is ambiguous. The same issue exists for Attribute.Floating.ts.