On Mon, Sep 05, 2005 at 04:41:56PM +0200, Rafael Garcia-Suarez wrote:
> On 9/5/05, Yitzchak Scott-Thoennes <[EMAIL PROTECTED]> wrote:
> > 
> > Any other feedback on making
> >    (LIST)[LIST]->
> > not need the ->?
> 
> I think I like the idea, and the patch seems safe. What I don't like,
> though, is the lack of tests for this patch. Also, a minor concern is
> that people might unknowingly write non-backwards-compatible code with
> 5.10 by using this construct.

Some basic tests:

--- t/op/ref.t.orig     2005-01-06 10:11:05.000000000 -0800
+++ t/op/ref.t  2005-09-05 08:05:18.629808000 -0700
@@ -8,7 +8,7 @@
 require 'test.pl';
 use strict qw(refs subs);
 
-plan (89);
+plan (96);
 
 # Test glob operations.
 
@@ -425,6 +425,23 @@
        'Accessing via a different NUL-containing name gives nothing');
 }
 
+# test derefs after list slice
+
+is ( ({foo => "bar"})[0]{foo}, "bar", 'hash deref from list slice w/o ->' );
+is ( ({foo => "bar"})[0]->{foo}, "bar", 'hash deref from list slice w/ ->' );
+is ( ([qw/foo bar/])[0][1], "bar", 'array deref from list slice w/o ->' );
+is ( ([qw/foo bar/])[0]->[1], "bar", 'array deref from list slice w/ ->' );
+is ( (sub {"bar"})[0](), "bar", 'code deref from list slice w/o ->' );
+is ( (sub {"bar"})[0]->(), "bar", 'code deref from list slice w/ ->' );
+
+# deref on empty list shouldn't autovivify
+{
+    local $@;
+    eval { ()[0]{foo} };
+    like ( "$@", "Can't use an undefined value as a HASH reference",
+           "deref of undef from list slice fails" );
+}
+
 # Bit of a hack to make test.pl happy. There are 3 more tests after it leaves.
 $test = curr_test();
 curr_test($test + 3);

As to your minor concern, that may be a reason to not include it in maint.
(Whether it's a bugfix or enhancement depends on how you interpret the doc.)

Reply via email to