This is a compile-time error:
(\$x = \1) = \2;
However, the following is legal code, but is untested (the 'OPf_MOD'
branch in pp_refassign() is not triggered by the test suite):
f(\$x = \1);
So this commit adds some tests. It assumes that the above code is
equivalent to:
\$x = \1;
f(\$x);
Whether the existing behaviour is sane is up for debate, but if
if we change it, it should be a deliberate choice, not an accidental
change not spotted by the existing tests.
set_up_inc("../lib");
}
-plan 198;
+plan 201;
eval '\$x = \$y';
like $@, qr/^Experimental aliasing via reference not enabled/,
}
}
+# Scalars in lvalue context
+
+{
+ my $s = 3;
+ my $t = 5;
+
+ sub foo1 {
+ ok ref($_[0]), "foo1(alias) passes ref";
+ is ${$_[0]}, 5, "foo1(alias) passes ref to t";
+ ${$_[0]} = 7;
+ }
+ foo1(\$s = \$t);
+ is $s, 7, "foo1(alias) passes ref to t"
+}
+
+
+
# Array Elements
sub expect_scalar_cx { wantarray ? 0 : \$_ }