The specialness of regexp refs mostly comes from either having an SV type of SVt_REGEXP on new perls, or from PERL_MAGIC_qr on older perls.
They also happen to be blessed into a class called `Regexp' by default and can be blessed into any package explicitly, but that doesn't actually influence how they behave as a regexp. Given that, I'd expect the RegexpRef type constraint to only accept things that are actually references to regexps - i.e. something of type SVt_REGEXP or with proper qr magic, not any reference blessed into the class `Regexp' or any of its subclasses. That will accept both regular regexp refs and regexp refs using re plugins. If someone wants to be less strict, which I'm not sure the point of would be, he should probably use a regular class type instead: isa => 'Regexp' Note that this might be a slightly backward-incompatible change. Currently the Object type constraint explicitly excludes things blessed into `Regexp', even if the reference points to, say, a hash. Also the RegexpRef constraint currently accepts any kind of blessed reference, not only blessed references to regexps. That'd have to change as well. The amount of code this change would break does seem minimal to me.
pgptNzpEvNzHo.pgp
Description: PGP signature