diff options
-rw-r--r-- | perly.act | 4 | ||||
-rw-r--r-- | perly.h | 2 | ||||
-rw-r--r-- | perly.tab | 2 | ||||
-rw-r--r-- | perly.y | 2 | ||||
-rw-r--r-- | t/op/for-many.t | 42 |
5 files changed, 46 insertions, 6 deletions
@@ -2070,7 +2070,7 @@ case 2: case 276: #line 1387 "perly.y" - { parser->in_my = 0; (yyval.opval) = (ps[-1].val.opval); } + { (yyval.opval) = (ps[-1].val.opval); } break; @@ -2183,6 +2183,6 @@ case 2: /* Generated from: - * e87297a1b718c1eb135698aef6d0fe1da0c008db89e13c13a2f746afc9dba3e3 perly.y + * 15f94e78bed944fe5a2da8ead4096a620ad573562953c479348c65e9eaa51629 perly.y * acf1cbfd2545faeaaa58b1cf0cf9d7f98b5be0752eb7a54528ef904a9e2e1ca7 regen_perly.pl * ex: set ro: */ @@ -224,6 +224,6 @@ int yyparse (void); /* Generated from: - * e87297a1b718c1eb135698aef6d0fe1da0c008db89e13c13a2f746afc9dba3e3 perly.y + * 15f94e78bed944fe5a2da8ead4096a620ad573562953c479348c65e9eaa51629 perly.y * acf1cbfd2545faeaaa58b1cf0cf9d7f98b5be0752eb7a54528ef904a9e2e1ca7 regen_perly.pl * ex: set ro: */ @@ -1448,6 +1448,6 @@ static const toketypes yy_type_tab[] = }; /* Generated from: - * e87297a1b718c1eb135698aef6d0fe1da0c008db89e13c13a2f746afc9dba3e3 perly.y + * 15f94e78bed944fe5a2da8ead4096a620ad573562953c479348c65e9eaa51629 perly.y * acf1cbfd2545faeaaa58b1cf0cf9d7f98b5be0752eb7a54528ef904a9e2e1ca7 regen_perly.pl * ex: set ro: */ @@ -1384,7 +1384,7 @@ my_scalar: scalar /* A list of scalars for "for my ($foo, $bar) (@baz)" */ list_of_scalars: list_of_scalars[list] PERLY_COMMA - { parser->in_my = 0; $$ = $list; } + { $$ = $list; } | list_of_scalars[list] PERLY_COMMA scalar { $$ = op_append_elem(OP_LIST, $list, $scalar); diff --git a/t/op/for-many.t b/t/op/for-many.t index 2fb839d4e5..ccf61631c9 100644 --- a/t/op/for-many.t +++ b/t/op/for-many.t @@ -8,6 +8,7 @@ BEGIN { use strict; use warnings; +use utf8; my @have; @@ -118,7 +119,7 @@ is("@have", 'A B C D E F', 'one-at-a-time'); # Arrays have an optimised case in pp_iter: { - no strict; + no strict 'vars'; @array = split ' ', 'Dogs have owners, cats have staff.'; @@ -460,4 +461,43 @@ is($redo, 3, 'redo reached thrice'); is($next, 2, 'next reached twice'); is($continue, 'xx', 'continue reached twice'); +{ + no strict 'vars'; + # Important that this is a package variable, so that we test that the parser + # ends the scope of the my at the ')' and generates the correct ops to read + # from the symbol table, not the pad. + + @Lamini = qw(alpaca guanaco llama vicuña); + + @have = (); + for my ($domestic, $wild) (@Lamini) { + push @have, "$domestic;$wild"; + } + is("@have", 'alpaca;guanaco llama;vicuña', 'comma test 0'); + + @have = (); + for my ($domestic, $wild,) (@Lamini) { + push @have, "$domestic;$wild"; + } + is("@have", 'alpaca;guanaco llama;vicuña', 'comma test 1'); + + @have = (); + for my ($domestic,, $wild) (@Lamini) { + push @have, "$domestic;$wild"; + } + is("@have", 'alpaca;guanaco llama;vicuña', 'comma test 2'); + + @have = (); + for my ($domestic,, $wild,) (@Lamini) { + push @have, "$domestic;$wild"; + } + is("@have", 'alpaca;guanaco llama;vicuña', 'comma test 3'); + + @have = (); + for my ($domestic,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, $wild) (@Lamini) { + push @have, "$domestic;$wild"; + } + is("@have", 'alpaca;guanaco llama;vicuña', 'comma test 42'); +} + done_testing(); |