summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-12 22:29:39 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-13 08:53:45 -0800
commitd408447cb636e46fcb4f7fe7d0909bb351b7ba22 (patch)
tree5a07e8d45558e7bd27dde0001f5f4accf8e9fa07 /t
parent6d91e95705f053bd53d2470dff80fa5df03f7213 (diff)
downloadperl-d408447cb636e46fcb4f7fe7d0909bb351b7ba22.tar.gz
Make scalar() propagate lvalueness
As mentioned in ticket #24346, scalar() should not change lvalueness. The fact that it did was a side effect of the implementation and a bug. foo(scalar substr(....)) should pass a substr lvalue to foo just as it would without scalar() or with a $ prototype (which is meant to be equivalent to scalar()). This also makes it possible to force scalar context in list assignment to lvalue subroutines, as in (foo(), scalar bar()) = @list.
Diffstat (limited to 't')
-rw-r--r--t/op/substr.t9
1 files changed, 8 insertions, 1 deletions
diff --git a/t/op/substr.t b/t/op/substr.t
index ceacdf6e47..abd5d7f630 100644
--- a/t/op/substr.t
+++ b/t/op/substr.t
@@ -23,7 +23,7 @@ $SIG{__WARN__} = sub {
BEGIN { require './test.pl'; }
-plan(381);
+plan(382);
run_tests() unless caller;
@@ -684,6 +684,13 @@ is($x, "\x{100}\x{200}\xFFb");
}
}
+# Also part of perl #24346; scalar(substr...) should not affect lvalueness
+{
+ my $str = "abcdef";
+ sub { $_[0] = 'dea' }->( scalar substr $str, 3, 2 );
+ is $str, 'abcdeaf', 'scalar does not affect lvalueness of substr';
+}
+
# [perl #24200] string corruption with lvalue sub
{