diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-07-09 19:18:45 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-07-09 19:19:51 -0700 |
commit | 777d9014444bb88a98ccd6c09ebb520cdc4c0d8b (patch) | |
tree | add55b04929f0bc1462315c6aa167b4bfa2c641e /proto.h | |
parent | fe57f3b7598666107c5e6e9c9ffd844da47ea527 (diff) | |
download | perl-777d9014444bb88a98ccd6c09ebb520cdc4c0d8b.tar.gz |
Propagate (non-)lvalue context through nested calls
Before this commit, this code would fail:
$foo = "foo";
sub foo :lvalue{ return index "foo","o" }
sub bar :lvalue { foo }
$x = bar;
(It would fail for ‘return $]’ as well. Whether it’s a PADTMP or a
read-only scalar makes no difference.)
foo would think it was being called in true lvalue context, because
the entersub op that called it (in bar) was marked that way, bar being
an lvalue sub as well.
The PUSHSUB macro in cop.h needed to be modified to account for
dynamic, or indetermine, context (i.e., indeterminable at compile
time). This happens when an entersub op is an argument to return or
the last statement in a subroutine. In those cases it has to propa-
gate the context from the caller.
So what we now do is this: Both lvalue and in-args flags are turned on
for an entersub op when op_lvalue is called with OP_LEAVESUBLV as the
type. Then PUSHSUB copies into the context stack only those flags
that are set both on the current entersub op and in the context stack
for the previous sub call.
Diffstat (limited to 'proto.h')
-rw-r--r-- | proto.h | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -4473,6 +4473,9 @@ PERL_CALLCONV void Perl_warner(pTHX_ U32 err, const char* pat, ...) #define PERL_ARGS_ASSERT_WARNER \ assert(pat) +PERL_CALLCONV I32 Perl_was_lvalue_sub(pTHX) + __attribute__warn_unused_result__; + PERL_CALLCONV void Perl_watch(pTHX_ char** addr) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_WATCH \ |