diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-09-20 14:49:04 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-10-10 21:54:05 -0700 |
commit | 4fec880468dad87517895b935b19a8d51e98b5a6 (patch) | |
tree | 3f154e38897ec820739ddb30a3b57e99a893eff4 /pp.c | |
parent | c0d680ed1b5f1cf4e78338bc96d26e636cbc60d6 (diff) | |
download | perl-4fec880468dad87517895b935b19a8d51e98b5a6.tar.gz |
First stab at lexical scalar aliases
No \my$x= yet. Only my $x; \$x =....
It does not work properly with variables closed over from outside;
hence, all the to-do tests fail still, since they do the assign-
ment in evals.
But this much works:
$ ./miniperl -Ilib -Mfeature=:all -e 'my $m; \$m = \$n; warn \$m; warn \$n'
Lvalue references are experimental at -e line 1.
SCALAR(0x7fa04b805510) at -e line 1.
SCALAR(0x7fa04b805510) at -e line 1.
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -6162,7 +6162,18 @@ PP(pp_runcv) PP(pp_refassign) { - DIE(aTHX_ "Unimplemented"); + dSP; + dTOPss; + if (!SvROK(sv)) DIE(aTHX_ "Assigned value is not a reference"); + if (SvTYPE(SvRV(sv)) > SVt_PVLV) + DIE(aTHX_ "Assigned value is not a scalar reference"); + SvREFCNT_dec(PAD_SV(ARGTARG)); + PAD_SETSV(ARGTARG, SvREFCNT_inc_NN(SvRV(sv))); + if (PL_op->op_flags & OPf_MOD) + SETs(sv_2mortal(newSVsv(sv))); + /* XXX else can weak references go stale before they are read, e.g., + in leavesub? */ + RETURN; } |