In perl.git, the branch sprout/lexsub-5.18 has been created
<http://perl5.git.perl.org/perl.git/commitdiff/a183b355664edd52456e891b72da9d326050e0cd?hp=0000000000000000000000000000000000000000>
at a183b355664edd52456e891b72da9d326050e0cd (commit)
- Log -----------------------------------------------------------------
commit a183b355664edd52456e891b72da9d326050e0cd
Author: Father Chrysostomos <[email protected]>
Date: Sat Jul 27 23:22:43 2013 -0700
perldelta: deep recursion warnings (07b2687d2/#118521)
M pod/perldelta.pod
commit 9a4c2565b8e795154abadc839aaa3018ff6d9b4f
Author: Father Chrysostomos <[email protected]>
Date: Sat Jul 13 14:31:31 2013 -0700
perldelta for bdbfc51a7b (undef constant my sub)
(cherry picked from commit 07a522a526321341d2a83a852eda7f6fecb333c9)
M pod/perldelta.pod
commit 804663d121853831babb5327f4afe37af5ba5829
Author: Father Chrysostomos <[email protected]>
Date: Sat Jul 13 11:57:02 2013 -0700
perldelta for #118305/88dbe4a
(cherry picked from commit 81d3ed5a0fa49c09ac57f7edc0917f345ff6b160)
M pod/perldelta.pod
commit 107e921d063604cf0b78ee2371b7ab1d03f69b83
Author: Father Chrysostomos <[email protected]>
Date: Mon Jun 10 00:50:47 2013 -0700
perldelta for lexsub syntax errors (3a74e0e282c)
(cherry picked from commit 3221bc400f3da87f0d721c2bf3501051fac946ea)
M pod/perldelta.pod
commit a1221657d9ff110a5521d5f4f7dda9c9ed2a36b0
Author: Father Chrysostomos <[email protected]>
Date: Mon Jun 10 00:49:26 2013 -0700
perldelta for two lexsub fixes
(cherry picked from commit 81748522aff12edb368615e9512781d00a2d5d5b)
M pod/perldelta.pod
commit 510f162848ed052ce0d7d3556ab6a9076b1ca8ae
Author: Father Chrysostomos <[email protected]>
Date: Sun Jun 23 12:06:11 2013 -0700
Stop undef &foo from crashing on lex subs
(cherry picked from commit bdbfc51a7bc15a2f0a187c1ef09a16838a4c9915)
M pp.c
M t/op/lexsub.t
commit c67a57e45fb9e35ae90420dec38715c471c52a3f
Author: Lukas Mai <[email protected]>
Date: Tue Jun 18 09:51:32 2013 +0200
don't crash on deep recursion warnings in lexical subs (#118521)
(cherry picked from commit 07b2687d22462e599adb759b7c0082fb12b3f33d)
M pp_hot.c
M t/op/lexsub.t
commit 986469e8aa23ceb3584ebcbdfee6076fe85dda8e
Author: Father Chrysostomos <[email protected]>
Date: Thu Jun 20 14:07:19 2013 -0700
[perl #118305] make dtrace sub-entry probe support lexsubs
No tests, because I donât know how to write them.
See also
<https://rt.perl.org/rt3/Ticket/Display.html?id=118305#txn-1221543>.
I have tested this manually, so I know it works and no longer crashes.
Hopefully someone else can follow this up with tests.
(cherry picked from commit 88dbe4af2506aa2aa6864e188ca115b5423d4f9b)
M cop.h
commit 06d344cf0950362c8644646c94f29a4ac3a4276e
Author: Father Chrysostomos <[email protected]>
Date: Sun Jun 2 13:25:24 2013 -0700
Fix crashes after syntax errors in lexical subs
Peter Martini fixed this in commit 89e006ae4e39db for our subs.
(Thank you, BTW, if you are reading this.)
The warning is expected; the assertion failure is not:
$ ./miniperl -Ilib -Mfeature=:all -e 'state sub a { is ref } a()'
The lexical_subs feature is experimental at -e line 1.
Assertion failed: (hek), function Perl_ck_subr, file op.c, line 10558.
Abort trap: 6
$ ./miniperl -Ilib -Mfeature=:all -e 'my sub a { is ref } a()'
The lexical_subs feature is experimental at -e line 1.
Assertion failed: (SvTYPE(_svmagic) >= SVt_PVMG), function
S_mg_findext_flags, file mg.c, line 398.
Abort trap: 6
$
The prototype CV for a my sub is stored in magic attached to the pad
name. The. The code to fetch the prototype CV for a my sub calls
mg_find on the pad name. If a syntax error occurs when the sub is be
ing compiled, the magic will never be attached, so the pad name (pad
names are currently SVs) will not have been upgraded to SVt_PVMG,
causing an assertion failure in mg_find, which only accepts SVs
thus upgraded.
When a pad entry is created, it is automatically filled with an empty
SV of the appropriate type. For a subroutine, this is a nameless CV
stub. CVs can be named in two ways, via GVs for package subs, or via
heks for lexical subs. This stub has neither and is truly nameless.
Since a lexical sub is never installed if it contains a syntax error,
this stub is visible during subsequent compilation in the same scope.
ck_subr wasnât prepared to handle a stub with absolutely no name
attached to it, since it is designed for handling sub calls where the
sub is known at compile time, so there must be a GV available to it,
unless the sub is lexical, and all lexical subs have heks.
This commit fixes the assumptions in both places. Exactly what hap-
pens and what is returned is not so important, as this only hap-
pens after a syntax error, when the op tree is going to be thrown
away anyway.
(cherry picked from commit 3a74e0e282cd5c2593f9477923d3bcb1f32ece37)
M op.c
M t/op/lexsub.t
commit daa05ff194599b8b008613c12abbe63a1690e427
Author: Father Chrysostomos <[email protected]>
Date: Sun Jun 2 00:54:09 2013 -0700
[perl #116735] Honour lexical prototypes when no parens are used
As Peter Martini noted in ticket #116735, lexical subs produce dif-
ferent op trees for âfoo 1â and âfoo(1)â. foo(1) produces an rv2cv
op with a padcv kid. The unparenthetical version produces just
a padcv op.
And the difference in op trees caused lexical sub calls to honour
prototypes only in the presence of parentheses, because rv2cv_op_cv
(which searches for the cv in order to check its prototype) was
expecting rv2cv+padcv.
Not realising there was a discrepancy between the two forms, and
noticing that foo() produces *two* newCVREF ops, in commit 279d09bf893
I made newCVREF return just a padcv op for lexical subs. At the time
I couldnât figure out why there were two rv2cv ops, and punted on
researching it.
This is how it works for package subs:
When a sub call is compiled, if there are parentheses, an implicit '&'
is fed to the parser. The token that follows is a WORD token with a
constant op attached to it, containing the name of the subroutine.
When the parser sees '&', it calls newCVREF on the const op to create
an rv2cv op.
For sub calls without parentheses, the token passed to the parser is
already an rv2cv op.
The resulting op tree is the same either way.
For lexical subs, I had the lexer emitting an rv2cv op in both paths,
which was why we got the double rv2cv when newCVREF was returning an
rv2cv for lexical subs.
The real solution is to call newCVREF in the lexer only when there
are no parentheses, since in that case the lexer is not going to call
newCVREF itself. That avoids a redundant newCVREF call. Hence, we
can have newCVREF always return an rv2cv op.
The result is that âfoo(1)â and âfoo 1â produce identical op trees
for
a lexical sub.
One more thing needed to change: The lexer was not looking at the
lexical prototype CV but simply the stub to be autovivified, so it
couldnât see the parameter prototype attached to the CV (the stub
doesnât have one).
The lexer needs to see the parameter prototype too, in order to deter-
mine precedence.
The logic for digging through pads to find the CV has been extracted
out of rv2cv_op_cv into a separate (non-API!) routine.
(cherry picked from commit 9a5e6f3cd84e6eaf40dad034fb9d25cb3361accc)
M embed.fnc
M embed.h
M op.c
M proto.h
M t/op/lexsub.t
M toke.c
commit a577946faac23421cbc37de4b630e96637f8263c
Author: Father Chrysostomos <[email protected]>
Date: Sat Jun 1 18:39:33 2013 -0700
Name lexical constants
$ ./perl -Ilib -Mfeature=:all -e 'my sub a(){44} a()'
The lexical_subs feature is experimental at -e line 1.
Assertion failed: (hek), function Perl_ck_subr, file op.c, line 10558.
Abort trap: 6
The experimental warning is expected. The assertion failure is not.
When a call checker is invoked, the name of the subroutine is passed
to it. op.c:ck_subr gets the name from the CVâs cv (CvGV) or, in the
case of lexical subs, from its name hek (CvNAME_HEK). If neither
exists, ck_subr cannot cope.
Lexical subs never have a GV pointer. Lexical constants were acci-
dentally having neither a GV pointer nor a hek. They should have a
hek, like other lexical subs.
(cherry picked from commit 83a72a15a3e8908c9fea8334e083e9329d425feb)
M op.c
M t/op/lexsub.t
commit bf4a62f42f5451ce7caaba7891dd82801a8a0df4
Author: Father Chrysostomos <[email protected]>
Date: Sat Jun 1 06:28:12 2013 -0700
lexsub.t: To-do tests for citing lex subs after errors
This currently causes assertion failures on debugging builds. On
non-debugging builds (untested), it probably crashes:
my sub a { foo ref } # foo must not exist
a();
(cherry picked from commit fe54d63b71ffdc66546e8a06b4ea561f58af2fc2)
M t/op/lexsub.t
-----------------------------------------------------------------------
--
Perl5 Master Repository