Revision
5252
Author
watson1978@gmail.com
Date
2011-03-04 15:05:12 -0800 (Fri, 04 Mar 2011)

Log Message

String#+ will concatenate only strings.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

assert_equal("foobar",   "foo" + "bar" )
assert_raise(TypeError){ "foo" + :bar  }

puts :ok
}}}

Modified Paths

Diff

Modified: MacRuby/trunk/string.c (5251 => 5252)


--- MacRuby/trunk/string.c	2011-03-04 11:55:41 UTC (rev 5251)
+++ MacRuby/trunk/string.c	2011-03-04 23:05:12 UTC (rev 5252)
@@ -2533,6 +2533,8 @@
 static VALUE
 rstr_plus(VALUE self, SEL sel, VALUE other)
 {
+    StringValue(other);
+
     rb_str_t *newstr = str_dup(RSTR(self));
     rb_str_t *otherstr = str_need_string(other);
     str_concat_string(newstr, otherstr);