summaryrefslogtreecommitdiff
path: root/t/mro/package_aliases.t
Commit message (Collapse)AuthorAgeFilesLines
* Add class_ok() and object_ok() to t/test.pl.Michael G. Schwern2011-11-171-2/+2
| | | | | | | | | | Change every existing instance of isa_ok() to use object_ok(). This is safe because before this point, t/test.pl's isa_ok() only worked on objects. lib/dbmt_common.pl is the last hold out because it uses Test::More. These are like isa_ok() but they also check if it's a class or an object. This lets the core tests defend against outlandish bugs while allowing t/test.pl to retain feature parity with Test::More.
* Followup to 088225f/[perl #88132]: packages ending with :Father Chrysostomos2011-04-151-4/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 088225f was not sufficient to fix the regression. It still exists for packages whose names end with a single colon. I discovered this when trying to determine why RDF::Trine was crashing with 5.14-to-be. In trying to write tests for it, I ended up triggering the same crash that RDF::Trine is having, but in a different way. In the end, it was easier to fix about three or four bugs (depending on how you count them), rather than try to fix only the regression that #88132 deals with (isa caches not updating when packages ending with colons are aliased), as they are all intertwined. The changes are as follows: Concerning the if (!(flags & ~GV_NOADD_MASK)...) statement in gv_stashpvn: Normally, gv_fetchpvn_flags (which it calls and whose retval is assigned to tmpgv) returns NULL if it has not been told to add anything and if the gv requested looks like a stash gv (ends with ::). If the number of colons is odd (foo:::), that code path is bypassed, so gv_stashpvn returns a GV without a hash. So gv_stashpvn tries to used that NULL hash and crashes. It should instead return NULL, to be consistent with the two-colon case. Blindly assigning a name to a stash does not work if the stash has multiple effective names. A call to mro_package_moved is required as well. So what gv_stashpvn was doing was insufficient. The parts of the mro code that check for globs or stash elems that contain stashes by looking for :: at the end of the name now take into account that the name might consist of a single : instead.
* [perl #88132] broken ISA lookup after aliasing packages ending with ::Father Chrysostomos2011-04-131-32/+42
| | | | | | | | | | | | | | | | | | | | | | gv_fetchpvn_flags did not always assign a name to a return HV ending with ::. This would result in code in various places skipping certain ‘stashes’ (in quotes because nameless HVs are technically not stashes) because they were nameless when they should not have been. So sometimes ISA caches would end up being out of date, as in the test cases posted with [perl #88132] (and incorporated into this patch). This commit fixes that by changing the parsing of glob names. Formerly, a :: was not considered a package separator if it came imme- diately after a ::. So foo:::: would become foo::/:: (with the final :: considered a regular stash entry, not a ‘stash’ stash entry) and foo:::::: would become foo::/:::/:. Now a :: is always a package separator. So *foo::::bar is accessible via $foo::{"::"}{bar} and *$foo:::::: via $foo::{"::"}{"::"}. This happens to fix [perl #88134] as well.
* Newly-created stashes may need effective names addedFather Chrysostomos2010-11-221-1/+20
|
* mro_package_moved must act on all effective namesFather Chrysostomos2010-11-221-1/+23
| | | | | | | | | | | | See the test case in the commit. It passes in 5.8.x and blead (as of this commit), but not 5.10-5.13.7. In every case the name to be passed to mro_gather_and_rename is cre- ated using an SV, so we might as well pass that instead of extracting the char array and length from it. That allows us to pass an AV instead, if there are multiple names to take into account.
* Make hv_undef leave HvENAME aloneFather Chrysostomos2010-11-201-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unless called from sv_clear. This is necessary as and undeffed stash, though it nominally becomes just a plain hash and is not a stash any more, is still to be found in the symbol table. It may even be in multiple places. HvENAME’s raison d’être is to keep track of this. If the effective name is deleted, then things can get out of sync as the test in the commit demonstrates. This can cause problems if the hash is turned back into a stash. This does not change the deletion of the HvNAME, which is the only difference between hv_clear and hv_undef on stashes that is visible from Perl. caller still returns (unknown) or __ANON__::.... I tried to make this into several small commits, but each part of it breaks things without the other parts, so this is one big commit. These are the various parts: • hv_undef no longer calls mro_package_named directly, as it deletes the effective name of the stash. It must only be called on sub- stashes, so hfreeentries has been modified to do that. • hv_name_set, which has erased the HvENAME when passed a null arg for the value ever since effective names were added (a special case put it just for hv_undef), now leaves the HvENAME alone, unless the new HV_NAME_SETALL flag (set to 2 to allow for UTF8 in future) is passed. • hv_undef does not delete the name before the call to hfreeentries during global destruction. That extra name deletion was added when hfreeentries stopped hiding the name, as CVs won’t be anonymised properly if they see it. It does not matter where the CVs point if they are to be freed shortly. This is just a speed optimisation, as it allows the name and effective name to be deleted in one fell swoop. Deleting just the name (not the effective name) can require a memory allocation. • hv_undef calls mro_isa_changed_in as it used to (before it started using mro_package_moved), but now it happens after the entries are freed. Calling it first, as 5.13.6 and earlier versions did, was simply wrong. • Both names are deleted from PL_stashcache. I inadvertently switched it back and forth between the two names in previous commits. Since it needed to be accounted for, it made no omit it, as that would just complicate things. (I think PL_stashcache is buggy, though I have yet to come up with a test case.) • sv_clear now calls Perl_hv_undef_flags with the HV_NAME_SETALL flag, which is passed through to the second hv_name_set call, after hfreeentries. That determines whether the effective names are deleted. • The changes at the end of hv_undef consist of pussyfooting to avoid unnecessary work. They make sure that everything is freed that needs to be and nothing is freed that must not be.
* Don’t skip mro_package_moved if the parent stash is renamedFather Chrysostomos2010-11-161-1/+18
| | | | | | | This stops S_hv_delete_common from skipping the call to mro_package_moved if the HvNAME of the stash containing the deleted glob is no longer valid, but the stash is still attached to some other part of the symbol table.
* Fix package assignment with nested aliased packagesFather Chrysostomos2010-11-111-1/+29
| | | | | | | | | | | | | | | | | | | | | This commit fixes package assignments like *foo:: = *bar:: when both foo and bar contain nested stashes that are aliases of each other. mro_package_moved (actually, its auxiliary routine) need to keep a list of stashes that have been seen as a separate list from those that are going to have mro_isa_changed_in called on them. Otherwise, some stashes will simply not be iterated through. See the test that this adds and its comments. @ISA = @ISA should never have any effect visible to Perl (with a capital), but it does in that test case, prior to this commit. This also fixes another bug that the test case triggered: riter was not being reset before the second iteration in mro_gather_and_rename. Also, the stashes HV (aka the ‘big list’) now holds refcounts on its elements, as that makes the code simpler as a result of the changes.
* Tests for [perl #77358]Father Chrysostomos2010-10-301-3/+27
|
* Fix a nested package deletion bugFather Chrysostomos2010-10-211-1/+21
| | | | | | | | | | | | In mro_package_moved, I was calling mro_isa_changed_in, instead of mro_package_moved, for a deleted package. So its subpackages were ignored. Exempli gratia, delete $::{'Cur::'} would call mro_isa_changed_in on Cur::Cur, but ignore Cur::Cur::Cur. I probably added this bug (or reinstated it, as it was in 5.13.5) in d056e33c1.
* [perl #78362] Make mro_package_moved check for recursionFather Chrysostomos2010-10-121-1/+8
| | | | | The existence of main::main::... caused mro_package_moved to break Text::Template, and probably Acme::Meta as well.
* Reset isa caches on nonexistent substashes when stash trees are movedFather Chrysostomos2010-10-121-1/+44
| | | | | | | | | | | | | | | | | This fixes the problem of isa cache linearisations’ and method caches’ not being reset on nonexistent packages when they are replaced with real packages as a result of parent stashes’ being moved. This can happen in cases like this: @left::ISA = 'outer::inner'; @right::ISA = 'clone::inner'; {package outer::inner} *clone:: = \%outer::; print "ok 1", "\n" if left->isa("clone::inner"); print "ok 2", "\n" if right->isa("outer::inner"); This changes mro_package_moved’s parameter list as documented in the diff for mro.c. See also the new comments in that function.
* Add an inheritance diagram to package_aliases.tFather Chrysostomos2010-10-101-0/+9
|
* Make more ways to move packages around reset isa cachesFather Chrysostomos2010-10-091-42/+76
| | | | | | | | This makes string-to-glob assignment and hashref-to-glob assignment reset isa caches by calling mro_package_moved, if the glob’s name ends with ::. Related to [perl #75176].
* Oops. Remove a duplicate require.Father Chrysostomos2010-10-091-1/+1
|
* Reset isa on stash manipulationFather Chrysostomos2010-10-091-1/+76
| | | | | | | | | | | | This only applies to glob-to-glob assignments and deletions of stash elements. Other types of stash manipulation are dealt with by subse- quent patches. It adds mro_package_moved, a private function that iterates through subpackages, calling mro_isa_changed_in on each. This is related to [perl #75176], but is not the same bug. It simply got in the way of fixing [perl #75176].
* MRO tests for isa() and package aliasesTorsten Schoenfeld2008-11-161-0/+33
Message-ID: <491F3008.4060205@gmx.de> p4raw-id: //depot/perl@34839