summaryrefslogtreecommitdiff
path: root/t/op/attrs.t
Commit message (Collapse)AuthorAgeFilesLines
* Stop attribute errors from leaking op treesFather Chrysostomos2011-10-101-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit moves attribute handling in newATTRSUB so that it happens after the op tree is attached to the sub. So when the sub is freed, the op tree goes with it, instead af leaking when an attribute han- dler dies. Witness what happens without that: $ PERL_DESTRUCT_LEVEL=2 ./perl -Ilib -le 'BEGIN {$^H{a}="b"}; sub foo:bar{1}' Invalid CODE attribute: bar at -e line 1 BEGIN failed--compilation aborted at -e line 1. Unbalanced string table refcount: (1) for "a" at (null) line 1 during global destruction. It was the ‘Unbalanced string table’ warnings that alerted me to the problem. The fairly new t/uni/attrs.t happens to trigger this bug. Not that this told me anything, but I did a binary search which lead me to this commit: commit b3ca2e834c3607fd8aa8736a51aa3a2b8bba1044 Author: Nicholas Clark <nick@ccl4.org> Date: Fri Mar 31 13:45:57 2006 +0000 Serialise changes to %^H onto the current COP. Return the compile time state of %^H as an eleventh value from caller. This allows users to write pragmas. That commit started indirectly storing HEKs in cops (in the hints hash), which means we have an easy way to tell when ops are leaking.
* attrs.t: Test for something I almost brokeFather Chrysostomos2011-06-221-0/+3
|
* attributes.pm: warn & don’t apply :lvalue to defined subsFather Chrysostomos2011-06-221-0/+31
| | | | | | | | This is something that ‘sub foo :lvalue;’ declarations do. This brings attributes.pm in line with them. See commits fff96ff and 885ef6f, ticket #68758, and <364E1F98-FDCC-49A7-BADB-BD844626B8AE@cpan.org>.
* Suppress proto warning from attrs.tFather Chrysostomos2011-06-101-1/+1
| | | | | attributes::get was being called before attributes.pm was loaded. Why this did not warn before I know not. Maybe that’s another bug....
* Fix my + attrs + list assignmentFather Chrysostomos2011-06-081-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This script works in 5.6.x: #!perl -l sub MODIFY_SCALAR_ATTRIBUTES { return } # need these sub MODIFY_ARRAY_ATTRIBUTES { return } # for it to sub MODIFY_HASH_ATTRIBUTES { return } # compile my ($x,@y,%z) : Bent = 72; # based on example from attributes.pm’s pod print $x; print "ok"; $ pbpaste|perl5.6.2 72 ok (pbpaste is a Mac command that outputs the clipboard contents.) In 5.8.0 to 5.8.8: $ pbpaste|perl5.8.1 ok So the assignment never happens. And with warnings: $ pbpaste|perl5.8.1 -w Bizarre copy of ARRAY in aassign at - line 5. In 5.8.9 it gets slightly worse: $ pbpaste|perl5.8.9 Bizarre copy of ARRAY in aassign at - line 5. So warnings are not required to trigger the error. If my ($x,@y,%z) is changed to my($x,$y), there is no error, but the assignment doesn’t happen. This was broken in 5.8.0 by this change: commit 95f0a2f1ffc68ef908768ec5d39e4102afd28c1e Author: Spider Boardman <spider@orb.nashua.nh.us> Date: Sat Dec 8 19:09:23 2001 -0500 Re: attributes are broken Message-Id: <200112090509.AAA02053@Orb.Nashua.NH.US> p4raw-id: //depot/perl@13543 (Is there a ‘hereby’ missing from that subject? :-) Oddly enough, that was the commit that put the attribute and list assignment example in attribute.pm’s pod. This change caused the bizarre assignment error to occur more often in 5.8.9 and 5.10.0, but I don’t think it’s actually relevant (just try- ng to see how long I can get this commit message): commit f17e6c41cacfbc6fe88a5ea5e01ba690dfdc7f2e Author: Rafael Garcia-Suarez <rgarciasuarez@gmail.com> Date: Wed Jul 5 20:00:10 2006 +0000 Fix a bug on setting OPpASSIGN_COMMON on a AASSIGN op when the left side is made out a list declared with our(). In this case OPpLVAL_INTRO isn't set on the left op, so we just remove that check. Add new tests. p4raw-id: //depot/perl@28488 What’s happening is that there is an extra pushmark in the list when attributes are present: $ perl5.14.0 -MO=Concise -e 'my ($a,@b):foo' o <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 39 -e:1) v:{ ->3 n <@> list vKPM/128 ->o 3 <0> pushmark vM/128 ->4 4 <0> padsv[$a:39,40] vM/LVINTRO ->5 5 <0> padav[@b:39,40] vM/LVINTRO ->6 6 <0> pushmark v ->7 <------- right here e <1> entersub[t3] vKS*/NOMOD,TARG ->f 7 <0> pushmark s ->8 8 <$> const[PV "attributes"] sM ->9 9 <$> const[PV "main"] sM ->a b <1> srefgen sKM/1 ->c - <1> ex-list lKRM ->b a <0> padsv[$a:39,40] sRM ->b c <$> const[PV "foo"] sM ->d d <$> method_named[PV "import"] ->e m <1> entersub[t4] vKS*/NOMOD,TARG ->n f <0> pushmark s ->g g <$> const[PV "attributes"] sM ->h h <$> const[PV "main"] sM ->i j <1> srefgen sKM/1 ->k - <1> ex-list lKRM ->j i <0> padsv[@b:39,40] sRM ->j k <$> const[PV "foo"] sM ->l l <$> method_named[PV "import"] ->m -e syntax OK That leaves an extra mark that confuses pp_aassign, which doesn’t know what it’s supposed to be reading and what it’s supposed to be assign- ing to (hence the bizarre copy). The pushmark is the result of the concatenation of two lists, the sec- ond one beginning with a pushmark (as listops do by default). The con- catenation occurs in Perl_my_attrs, at this spot (in the ‘else’): if (rops) { if (maybe_scalar && o->op_type == OP_PADSV) { o = scalar(op_append_list(OP_LIST, rops, o)); o->op_private |= OPpLVAL_INTRO; } else o = op_append_list(OP_LIST, o, rops); } So this commit make that ‘else’ clause check for a pushmark and oblit- erate it if present, before concatenating the lists.
* Refactor 6 tests in t/op and t/run to use skip_all_if_miniperl().Nicholas Clark2011-03-071-4/+1
|
* Fix typos (spelling errors) in t/*.Peter J. Acklam) (via RT2011-01-071-1/+1
| | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81916] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81916 >
* [perl #68658] attributes turn "state" into "my"Father Chrysostomos2010-12-081-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is for two reasons: • In S_my_kid, the attribute-handling code comes before the code that marks the padop as being a state instead of a my, which it knows to do based on the value of PL_parser->in_my. The attribute-handling code begins by setting PL_parser->in_my to FALSE, preventing the code that follows from doing its job. So now PL_parser->in_my is read at the top of S_my_kid, before the attribute code, with the statehood recorded in a boolean. Then the code that marks the padop as being state checks that boolean instead of in_my. • A lexical variable declaration that has an attribute and is assigned to in the same expression compiles to something similar to: (attributes->import(... \$x ...), my $x) = 3; where the list is actually in scalar context, returning the my $x which is then assigned to (something that cannot be expressed directly in Perl syntax). So Perl_ck_sassign needs to take that list op into account when creating the ‘once’ op that actually makes state assignment work. Up till now it was just looking for a padsv on its LHS. This commit makes it check also for a list op whose last item is a padsv.
* Suppress warning from t/op/attrs.tFather Chrysostomos2010-11-301-2/+2
|
* Use ' to avoid interpolationFather Chrysostomos2010-11-301-1/+1
|
* [perl #68560] calling closure prototype SEGVsFather Chrysostomos2010-11-291-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a closure is created, the original sub is cloned (except that the op tree is shared). That original sub (called the closure prototype) is not usually accessible to perl. An attribute handler (MODIFY_CODE_ATTRIBUTES) is passed a reference to it, however. If that code reference is called within the attribute handler, an ‘Undefined subroutine called’ error results, because the op tree has not been attached yet. If that code reference is stashed away and called after the attribute handler returns, it will most likely crash. This is because its pad is full of nulls. A regular $proto->() or &$proto() call that sets up @_ will crash in attempting to do so. A &$proto call will bypass that, but attempting to read any lexical variables from the containing scope will cause a crash. Any operator that uses TARG (i.e., most of them) will crash. So this commit puts a check for closure prototypes in pp_entersub. It produces a new error message, ‘Closure prototype called’. This does introduce a backward-incompatible change: code like this used to work: sub MODIFY_CODE_ATTRIBUTES { $'proto = $_[1] } { my $x; () = sub :attr { () = $x; print "hello\n" } } &$'proto; But writing a useful subroutine that tiptoes past the crashes is so difficult that I think this breakage is acceptable.
* Make my $pi := 4; a syntax error.Nicholas Clark2010-11-281-2/+55
| | | | | Previously it interpreted := as an empty attribute list, and issued a deprecation warning. This change permits := to be used as a binding operator.
* permit labels to appear before declarationsZefram2010-10-231-1/+1
| | | | | | | | Include <label> in productions before <decl> and <package_block>. This means that labels can now appear at the beginning of all statement-like things. There was no technical reason for the restriction of labels to substantive statements, and that restriction in any case couldn't be applied to PLUGSTMT-based plugged-in declarations.
* Retain builtin attributes from pre-declaration. Fixes [perl #68758].Gerard Goossen2010-01-101-1/+6
|
* Ignore a lvalue attribute after the subroutine has been defined, and warn ↵Gerard Goossen2010-01-101-4/+4
| | | | about it. Fixes part of [perl #68758].
* Move the test for RT #49472 to op/attrs.t from comp/require.tNicholas Clark2009-10-081-1/+13
|
* Fix [perl #66970] Incorrect coderef in MODIFY_CODE_ATTRIBUTESZefram2009-09-061-1/+31
| | | | | | | | | | | | | | | | Attribute handlers being applied to a temporary CV has actually been reported as a bug, #66970. The attached patch fixes the bug, by changing the order in which things happen: attributes are now applied after the temporary CV has been merged into the existing CV or has otherwise been added to the appropriate GV. The change breaks part of Attribute::Handlers. Part of A:H searches the package to find the name of the sub to which a :ATTR attribute is being applied, and the correct time at which to launch that search depends crucially on the order in which the CV construction events occur. So this patch also includes a change to A:H, to make it detect which way things happen. The resulting A:H works either way, which is essential for its dual-life nature.
* Skip tests that use attributes.pm under miniperlRafael Garcia-Suarez2009-05-251-2/+6
|
* Allow typed arrays and hashesVincent Pit2009-05-111-2/+5
|
* Deprecate using "unique" with the attributes pragma.Nicholas Clark2009-04-121-2/+3
|
* Deprecate using "locked" with the attributes pragma.Nicholas Clark2009-04-121-3/+9
|
* Deprecate use of the attribute :locked on subroutines.Nicholas Clark2009-04-121-15/+5
|
* Some more missing isGV_with_GP()sBen Morrow2008-06-281-1/+8
| | | | | Message-ID: <20080628160017.GA81579@osiris.mauzo.dyndns.org> p4raw-id: //depot/perl@34092
* Remove support for assertions and -ARafael Garcia-Suarez2007-06-051-1/+0
| | | p4raw-id: //depot/perl@31333
* Unify the two warnings "Can't declare %s in %s", in line with what'sRafael Garcia-Suarez2006-11-201-2/+2
| | | | | documented in perldiag. p4raw-id: //depot/perl@29330
* Regression test for attributes 'reserved' warning,Rafael Garcia-Suarez2006-08-271-1/+7
| | | | | by Jerry D. Hedden p4raw-id: //depot/perl@28761
* [perl #36297] builtin attrs on subrutine declarations Salvador FandiXXo2005-06-151-0/+5
| | | | | | From: Salvador "FandiXXo" (via RT) <perlbug-followup@perl.org> Message-ID: <rt-3.0.11-36297-115797.8.75971493113916@perl.org> p4raw-id: //depot/perl@24851
* Make "assertion" attribute code and test conditionalNicholas Clark2005-01-191-2/+3
| | | p4raw-id: //depot/perl@23827
* Rafael spotted that my changes caused warnings. So clean up.Nicholas Clark2005-01-051-0/+1
| | | p4raw-id: //depot/perl@23747
* Check all attributes in modify_SV_attributes are recognised.Nicholas Clark2005-01-041-4/+32
| | | | | Fix bug where 'assertion' was always rejected as invalid. p4raw-id: //depot/perl@23744
* More tests for the attribute syntax, from theRafael Garcia-Suarez2002-08-081-1/+19
| | | | | attributes manpage. p4raw-id: //depot/perl@17705
* Fix bug #16080 : an attribute list should end at '}'Rafael Garcia-Suarez2002-08-081-1/+7
| | | p4raw-id: //depot/perl@17704
* Re: [perl #15898] coredump with variable ourRafael Garcia-Suarez2002-08-081-143/+45
| | | | | Message-id: <20020802234421.11c62fe6.rgarciasuarez@free.fr> p4raw-id: //depot/perl@17699
* Re: perl 5.7.3 + XS lvalue subsSpider Boardman2002-03-291-0/+8
| | | | | Message-Id: <200203290552.AAA47443@leggy.zk3.dec.com> p4raw-id: //depot/perl@15592
* Re: perl 5.7.3 + XS lvalue subsSpider Boardman2002-03-281-0/+6
| | | | | Message-Id: <200203280152.UAA415562@leggy.zk3.dec.com> p4raw-id: //depot/perl@15565
* Re: attributes are brokenSpider Boardman2001-12-091-3/+29
| | | | | Message-Id: <200112090509.AAA02053@Orb.Nashua.NH.US> p4raw-id: //depot/perl@13543
* Re: [patch] GvSHAREDDoug MacEachern2001-02-111-2/+3
| | | | | | | | | | | | | | | | | | | Date: Sat, 10 Feb 2001 14:04:40 -0800 (PST) Message-ID: <Pine.LNX.4.21.0102101356000.15298-100000@mako.covalent.net> Subject: Re: [patch] GvSHARED From: Doug MacEachern <dougm@covalent.net> Date: Sat, 10 Feb 2001 15:00:54 -0800 (PST) Message-ID: <Pine.LNX.4.21.0102101453220.15298-100000@mako.covalent.net> Subject: [patch] attributes.pm support for `shared' From: Doug MacEachern <dougm@covalent.net> Date: Sat, 10 Feb 2001 20:08:48 -0800 (PST) Message-ID: <Pine.LNX.4.21.0102102004190.15298-100000@mako.covalent.net> our() attributes were ignored, our :shared pieces missing, allow attributes.pm to turn on shared. p4raw-id: //depot/perl@8766
* Re: [PATCH blead] Fix segfault in gv_handler/mg_findDaniel Chetlin2000-12-281-0/+4
| | | | | Message-ID: <20001224040949.B3090@darkstar> p4raw-id: //depot/perl@8236
* Use minimal @INC in tests, most of the time just '../lib',Mike Guy2000-08-291-1/+1
| | | | | | | | so that we simply can't pick up stuff from other Perls than the one we are testing. Pointed out by Subject: Re: [PATCH: 6757] make new Storable tests forgiving of places where not built Message-Id: <E13SKH1-00031D-00@virgo.cus.cam.ac.uk> p4raw-id: //depot/perl@6874
* revised attribute syntax: C<my $foo :a :b :c>, C<my $foo : a b c>Gurusamy Sarathy2000-01-261-2/+2
| | | | | and C<my $foo : a : b : c> are all valid (from Spider Boardman) p4raw-id: //depot/perl@4907
* sub : attrlistSpider Boardman1999-08-291-0/+176
To: Mailing list Perl5 <perl5-porters@perl.org> Message-Id: <199908290702.DAA32191@Orb.Nashua.NH.US> p4raw-id: //depot/cfgperl@4043