# New Ticket Created by  Jeff Horwitz 
# Please include the string:  [perl #49620]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=49620 >


Empty declarations in lolcode are clobbering previous values of the same 
variable.  For example, this code prints nothing:

HAI 1.2
I HAS A CHEEZBURGER ITZ "yummy"
I HAS A CHEEZBURGER
VISIBLE CHEEZBURGER
KTHXBYE

The attached patch fixes this problem and adds two tests to 01-vars.t.

Coke notes that while this example fails as a standalone script, it works 
in the context of a test file.  This will need to be investigated further.

-jeff
Index: languages/lolcode/t/01-vars.t

===================================================================

--- languages/lolcode/t/01-vars.t       (revision 24723)

+++ languages/lolcode/t/01-vars.t       (working copy)

@@ -1,5 +1,5 @@

 HAI 1.2

-  VISIBLE "1..4"

+  VISIBLE "1..6"

 

   BTW THIS IS COMMENT OK?

   I HAS A CHEEZBURGER ITZ "ok "

@@ -20,5 +20,15 @@

   I HAS A ANY ITZ "ok 4"

   VISIBLE ANY

 

+  BTW EMPTY DECLARATIONS SHOULDN'T CLOBBER

+  I HAS A RESULT ITZ "ok 5"

+  I HAS A RESULT

+  VISIBLE RESULT

+

+  BTW MULTIPLE DECLARATIONS WITH ASSIGNMENTS SHOULD

+  I HAS A ANOTHER ITZ "not ok 6"

+  I HAS A ANOTHER ITZ "ok 6"

+  VISIBLE ANOTHER

+

   BTW vim: set filetype=lolcode :

 KTHXBYE

Index: languages/lolcode/src/parser/actions.pm

===================================================================

--- languages/lolcode/src/parser/actions.pm     (revision 24723)

+++ languages/lolcode/src/parser/actions.pm     (working copy)

@@ -47,8 +47,8 @@

 }

 

 method declare($/) {

-    $($<variable>).isdecl(1);

     if ($<expression>) {

+        $($<variable>).isdecl(1);

         # XXX Someone clever needs to refactor this into C<assign>

         my $past := PAST::Op.new( :pasttype('bind'), :node( $/ ) );

         $past.push( $( $<variable> ) );

Reply via email to