perlpunk / YAML-PP-p5

A YAML 1.2 processor in perl
https://metacpan.org/pod/YAML::PP
24 stars 8 forks source link

On combining different resolver types #19

Closed pplu closed 5 years ago

pplu commented 5 years ago

When implementing a "catchall" resolver in https://github.com/pplu/cfn-perl/tree/feature/yaml_support, I found out that combining some resolvers has unexpected behaviour:

$schema->add_sequence_resolver(tag => '!X', ...);
$schema->add_sequence_resolver(tag => qr/^!.*/, ...);

I was expecting the !X to be processed by the first resolver, when in fact, it gets processed always by the last one. I was adding specific resolvers for each tag, and wanted a "catchall" resolver for dying when an unsupported tag was found.

I just wanted you to notice this as feedback, since I think not many people are using these APIs.

I don't need this as a feature, since I've moved the code to only having one resolver for each type (scalar, sequence, mapping), and dispatching depending on the tag detected (https://github.com/pplu/cfn-perl/blob/3aeef4fc0d957e77a5defc7835b784cf2501f3cd/lib/Cfn/YAML/Schema.pm#L51)

perlpunk commented 5 years ago

Yes, you're right, the order of the resolvers was wrong. Fixed in 6e95b6bc, thanks!

perlpunk commented 5 years ago

Fixed in v0.017 :)