This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Allow typed arrays and hashes
authorVincent Pit <perl@profvince.com>
Sat, 9 May 2009 12:19:19 +0000 (14:19 +0200)
committerVincent Pit <perl@profvince.com>
Mon, 11 May 2009 17:07:05 +0000 (19:07 +0200)
ext/Attribute-Handlers/t/multi.t
op.c
t/op/attrs.t

index a8156c2..31b24d1 100644 (file)
@@ -7,6 +7,10 @@ BEGIN {
     }
 }
 
     }
 }
 
+# This test file contains 57 tests.
+# You need to number them manually. Don't forget to update this line for the
+# next kind hacker.
+
 END {print "not ok 1\n" unless $loaded;}
 use v5.6.0;
 use Attribute::Handlers;
 END {print "not ok 1\n" unless $loaded;}
 use v5.6.0;
 use Attribute::Handlers;
@@ -56,6 +60,22 @@ sub x1 :Lastly(1,44) {}
 
 my Test $x2 :Dokay(1,5);
 
 
 my Test $x2 :Dokay(1,5);
 
+if ($] < 5.011) {
+ ::ok(1, $_, '# skip : invalid before 5.11') for 55 .. 57;
+} else {
+ my $c = $::count;
+ eval '
+  my Test @x2 :Dokay(1,55);
+  my Test %x2 :Dokay(1,56);
+ ';
+ $c = $c + 2 - $::count;
+ while ($c > 0) {
+  ::ok(0, 57 - $c);
+  --$c;
+ }
+ ::ok(!$@, 57);
+}
+
 package Test;
 my $x3 :Dokay(1,6);
 my Test $x4 :Dokay(1,7);
 package Test;
 my $x3 :Dokay(1,6);
 my Test $x4 :Dokay(1,7);
diff --git a/op.c b/op.c
index be98c3f..63530b3 100644 (file)
--- a/op.c
+++ b/op.c
@@ -399,14 +399,6 @@ Perl_allocmy(pTHX_ const char *const name)
     /* check for duplicate declaration */
     pad_check_dup(name, is_our, (PL_curstash ? PL_curstash : PL_defstash));
 
     /* check for duplicate declaration */
     pad_check_dup(name, is_our, (PL_curstash ? PL_curstash : PL_defstash));
 
-    if (PL_parser->in_my_stash && *name != '$') {
-       yyerror(Perl_form(aTHX_
-                   "Can't declare class for non-scalar %s in \"%s\"",
-                    name,
-                    is_our ? "our"
-                           : PL_parser->in_my == KEY_state ? "state" : "my"));
-    }
-
     /* allocate a spare slot and store the name in that slot */
 
     off = pad_add_name(name,
     /* allocate a spare slot and store the name in that slot */
 
     off = pad_add_name(name,
index 5ba0fda..5e75e50 100644 (file)
@@ -10,7 +10,7 @@ BEGIN {
     require './test.pl';
 }
 
     require './test.pl';
 }
 
-plan 83;
+plan 84;
 
 $SIG{__WARN__} = sub { die @_ };
 
 
 $SIG{__WARN__} = sub { die @_ };
 
@@ -82,7 +82,10 @@ eval 'my A $x : plugh;';
 is $@, '';
 
 eval 'package Cat; my Cat @socks;';
 is $@, '';
 
 eval 'package Cat; my Cat @socks;';
-like $@, qr/^Can't declare class for non-scalar \@socks in "my"/;
+like $@, '';
+
+eval 'my Cat %nap;';
+like $@, '';
 
 sub X::MODIFY_CODE_ATTRIBUTES { die "$_[0]" }
 sub X::foo { 1 }
 
 sub X::MODIFY_CODE_ATTRIBUTES { die "$_[0]" }
 sub X::foo { 1 }