Skip Menu |

This queue is for tickets about the Type-Tiny CPAN distribution.

Report information
The Basics
Id: 132583
Status: resolved
Priority: 0/
Queue: Type-Tiny

People
Owner: Nobody in particular
Requestors: SNEZ [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: ClassName constraint for a package with empty ISA is inconsistent with Type::Tiny
When a package has an ISA declared but doesn't have any entries, the ClassName constraint from Type::Tiny (PP implementation) is true, however, the XS version is not. PERL_TYPE_TINY_XS=0 perl -MTypes::Standard=is_ClassName -le '{package Foo;our @ISA} print is_ClassName("Foo") ? "Class" : "Not Class"' Show quoted text
> Class
PERL_TYPE_TINY_XS=1 perl -MTypes::Standard=is_ClassName -le '{package Foo;our @ISA} print is_ClassName("Foo") ? "Class" : "Not Class"' Show quoted text
> Not Class
After some digging it turns out the XS version checks @ISA size as well - excerpt from typetiny_is_class_loaded in Util.xs : if (( gvp = (GV**)hv_fetchs(stash, "ISA", FALSE) )) { if(isGV(*gvp) && GvAV(*gvp) && av_len(GvAV(*gvp)) != -1){ return TRUE; } } I'm not sure which was the correct one and which is the bug but at the very least they should behave the same.
I'm pretty sure the PP implementation is correct in this case. If a package has an @ISA and nothing else, it's possible to use it as a class in a useful manner.
Oh, I re-read it, and @ISA exists but is empty. Hmmm. This is a weird case. I think probably the PP code needs to be changed.
Because I think the XS behaviour is more useful, I've changed the PP code to be more in line with that. https://github.com/tobyink/p5-type-tiny/commit/492426dc48f6976868351f2a93fe1c5632f1a70f This is a weird edge case, so I don't think it's worth releasing a new version of Type::Tiny just for this one fix. So it'll just get included in the next release whenever that happens.