From: Vincent Pit Date: Sat, 9 May 2009 12:19:19 +0000 (+0200) Subject: Allow typed arrays and hashes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d5e98372e6efc414e818f1ed2d33156eb6ca6200;p=p5sagit%2Fp5-mst-13.2.git Allow typed arrays and hashes --- diff --git a/ext/Attribute-Handlers/t/multi.t b/ext/Attribute-Handlers/t/multi.t index a8156c2..31b24d1 100644 --- a/ext/Attribute-Handlers/t/multi.t +++ b/ext/Attribute-Handlers/t/multi.t @@ -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; @@ -56,6 +60,22 @@ sub x1 :Lastly(1,44) {} 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); diff --git a/op.c b/op.c index be98c3f..63530b3 100644 --- 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)); - 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, diff --git a/t/op/attrs.t b/t/op/attrs.t index 5ba0fda..5e75e50 100644 --- a/t/op/attrs.t +++ b/t/op/attrs.t @@ -10,7 +10,7 @@ BEGIN { require './test.pl'; } -plan 83; +plan 84; $SIG{__WARN__} = sub { die @_ }; @@ -82,7 +82,10 @@ eval 'my A $x : plugh;'; 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 }