MARK = newsp + 1;
EXTEND_MORTAL(1);
if (MARK == SP) {
- if (SvFLAGS(TOPs) & (SVs_TEMP | SVs_PADTMP | SVf_READONLY)) {
+ /* Temporaries are bad unless they happen to be elements
+ * of a tied hash or array */
+ if (SvFLAGS(TOPs) & (SVs_TEMP | SVs_PADTMP | SVf_READONLY) &&
+ !(SvRMAGICAL(TOPs) && mg_find(TOPs, PERL_MAGIC_tiedelem))) {
LEAVE;
cxstack_ix--;
POPSUB(cx,sv);
-print "1..68\n";
+print "1..72\n";
BEGIN {
chdir 't' if -d 't';
print "not " unless join(':', @ary) eq "1:2:6";
print "ok 64\n";
+# check that an element of a tied hash/array can be assigned to via lvalueness
+
+package Tie_Hash;
+
+our ($key, $val);
+sub TIEHASH { bless \my $v => __PACKAGE__ }
+sub STORE { ($key, $val) = @_[1,2] }
+
+package main;
+sub lval_tie_hash : lvalue {
+ tie my %t => 'Tie_Hash';
+ $t{key};
+}
+
+eval { lval_tie_hash() = "value"; };
+
+print "# element of tied hash: $@\nnot " if $@;
+print "ok 65\n";
+
+print "not " if "$Tie_Hash::key-$Tie_Hash::val" ne "key-value";
+print "ok 66\n";
+
+
+package Tie_Array;
+
+our @val;
+sub TIEARRAY { bless \my $v => __PACKAGE__ }
+sub STORE { $val[ $_[1] ] = $_[2] }
+
+package main;
+sub lval_tie_array : lvalue {
+ tie my @t => 'Tie_Array';
+ $t[0];
+}
+
+eval { lval_tie_array() = "value"; };
+
+print "# element of tied array: $@\nnot " if $@;
+print "ok 67\n";
+
+print "not " if $Tie_Array::val[0] ne "value";
+print "ok 68\n";
+
require './test.pl';
-curr_test(65);
+curr_test(69);
TODO: {
local $TODO = 'test explicit return of lval expr';