This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix MAD handling of package block syntax
[perl5.git] / perly.y
diff --git a/perly.y b/perly.y
index 691ae94..edbcb19 100644 (file)
--- a/perly.y
+++ b/perly.y
@@ -246,8 +246,7 @@ line        :       label cond
                        { $$ = newSTATEOP(0, NULL,
                                 newWHILEOP(0, 1, (LOOP*)(OP*)NULL,
                                            NOLINE, (OP*)NULL, $1,
-                                           (OP*)NULL, 0));
-                         TOKEN_GETMAD($1,((LISTOP*)$$)->op_first,'L'); }
+                                           (OP*)NULL, 0)); }
        |       label PLUGSTMT
                        { $$ = newSTATEOP(0, PVAL($1), $2); }
        ;
@@ -667,9 +666,16 @@ package :  PACKAGE WORD WORD ';'
 
 package_block: PACKAGE WORD WORD '{' remember
                        {
+                         int save_3_latefree = $3->op_latefree;
+                         $3->op_latefree = 1;
                          package($3);
-                         if ($2)
+                         $3->op_latefree = save_3_latefree;
+                         if ($2) {
+                             int save_2_latefree = $2->op_latefree;
+                             $2->op_latefree = 1;
                              package_version($2);
+                             $2->op_latefree = save_2_latefree;
+                         }
                        }
                    lineseq '}'
                        { if (PL_parser->copline > (line_t)IVAL($4))
@@ -677,6 +683,9 @@ package_block:      PACKAGE WORD WORD '{' remember
                          $$ = block_end($5, $7);
                          TOKEN_GETMAD($4,$$,'{');
                          TOKEN_GETMAD($8,$$,'}');
+                         op_free($3);
+                         if ($2)
+                             op_free($2);
                        }
        ;