summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--parse.y4
-rw-r--r--test/ruby/test_literal.rb9
-rw-r--r--version.h2
4 files changed, 18 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 160143c179..1e87695059 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Nov 28 06:28:55 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (literal_concat_gen, evstr2dstr_gen): keep literal
+ encoding beginning with an interpolation same as the source file
+ encoding. [ruby-core:70703] [Bug #11519]
+
Sat Nov 28 06:12:32 2015 NARUSE, Yui <naruse@ruby-lang.org>
* ext/openssl/ossl_ssl.c (ssl_npn_select_cb): explicitly raise error
diff --git a/parse.y b/parse.y
index 9df51a19b9..dfeadb0918 100644
--- a/parse.y
+++ b/parse.y
@@ -8744,7 +8744,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail)
htype = nd_type(head);
if (htype == NODE_EVSTR) {
- NODE *node = NEW_DSTR(Qnil);
+ NODE *node = NEW_DSTR(STR_NEW0());
head = list_append(node, head);
htype = NODE_DSTR;
}
@@ -8817,7 +8817,7 @@ static NODE *
evstr2dstr_gen(struct parser_params *parser, NODE *node)
{
if (nd_type(node) == NODE_EVSTR) {
- node = list_append(NEW_DSTR(Qnil), node);
+ node = list_append(NEW_DSTR(STR_NEW0()), node);
}
return node;
}
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index ed5f83655c..302f487bb6 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -102,6 +102,15 @@ class TestRubyLiteral < Test::Unit::TestCase
assert_equal('FooBar', b, 'r3842')
end
+ def test_dstring_encoding
+ bug11519 = '[ruby-core:70703] [Bug #11519]'
+ ['"foo#{}"', '"#{}foo"', '"#{}"'].each do |code|
+ a = eval("#-*- coding: utf-8 -*-\n#{code}")
+ assert_equal(Encoding::UTF_8, a.encoding,
+ proc{"#{bug11519}: #{code}.encoding"})
+ end
+ end
+
def test_dsymbol
assert_equal :a3c, :"a#{1+2}c"
end
diff --git a/version.h b/version.h
index ee67d7bdaa..7b6d97b78b 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.4"
#define RUBY_RELEASE_DATE "2015-11-28"
-#define RUBY_PATCHLEVEL 205
+#define RUBY_PATCHLEVEL 206
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 11