Hi!

I found this comment in the ParserSupport.java:

// Ruby actually has a special case for StrNode, but I cannot actually get one 
// to occur.  I am asserting on ListNode to help flag the case.

and, more or less accidentally while testing our rewrite-visitor, some code to 
produce it:

"i" "#{4}u"

I've attached a patch containing the fix and a test for it.
? literal_concat_str_and_dstr.patch
Index: src/org/jruby/parser/ParserSupport.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/parser/ParserSupport.java,v
retrieving revision 1.35
diff -u -r1.35 ParserSupport.java
--- src/org/jruby/parser/ParserSupport.java	3 May 2006 03:04:58 -0000	1.35
+++ src/org/jruby/parser/ParserSupport.java	10 Jun 2006 13:20:54 -0000
@@ -725,11 +725,12 @@
         		((ListNode) head).add((Node) tail);
         	}
         } else if (tail instanceof DStrNode) {
-            // Ruby actually has a special case for StrNode, but I cannot actually get one to
-        	// occur.  I am asserting on ListNode to help flag the case.
-
-            assert head instanceof ListNode;
-            return list_concat((ListNode) head, tail);
+            if(head instanceof StrNode){
+	        ((DStrNode)tail).childNodes().add(0, head);
+		return tail;
+	    }
+	    else
+            	return list_concat((ListNode) head, tail);
 
         } else if (tail instanceof EvStrNode) {
         	if (head instanceof StrNode) {
Index: test/testStringEval.rb
===================================================================
RCS file: /cvsroot/jruby/jruby/test/testStringEval.rb,v
retrieving revision 1.3
diff -u -r1.3 testStringEval.rb
--- test/testStringEval.rb	10 Sep 2002 18:13:31 -0000	1.3
+++ test/testStringEval.rb	10 Jun 2006 13:20:54 -0000
@@ -7,3 +7,6 @@
 #########    test2   #################
 test_ok('Ho! Ho! Ho! Merry Christmas' == "#{'Ho! '*3}Merry Christmas" )
 
+#########    test3   #################
+test_ok('Say: Ho! Ho! Ho! Merry Christmas' == "Say: " "#{'Ho! '*3}Merry Christmas" )
+

Attachment: pgpC1Fafe6Dta.pgp
Description: PGP signature

_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel

Reply via email to