File handles take priority over stashes for method dispatch. Assigning a
file handle to a typeglob potentially creates a file handle where one did
not exist before. As PL_stashcache only contains entries for names which
unambiguously resolve to stashes, such a change may mean that PL_stashcache
now contains an invalid entry. As it's hard to work out exactly which entries
might be affected, simply flush the entire cache and let it rebuild itself.
assert(mg);
Perl_magic_clearisa(aTHX_ NULL, mg);
}
+ else if (stype == SVt_PVIO) {
+ DEBUG_o(Perl_deb(aTHX_ "glob_assign_ref clearing PL_stashcache\n"));
+ /* It's a cache. It will rebuild itself quite happily.
+ It's a lot of effort to work out exactly which key (or keys)
+ might be invalidated by the creation of the this file handle.
+ */
+ hv_clear(PL_stashcache);
+ }
break;
}
SvREFCNT_dec(dref);
*Color::H1 = *Colour::H1{IO};
is(Colour::H1->getline(), <DATA>, 'read from a file');
- { local $::TODO = "regression introduced when PL_stashcache was first added";
is(Color::H1->getline(), <DATA>,
'file handles take priority after typeglob assignment');
- }
*Color::H1 = *CLOSED{IO};
{
- local $::TODO = "regression introduced when PL_stashcache was first added";
no warnings 'io';
is(Color::H1->getline(), undef,
"assigning a closed a file handle doesn't change object resolution");