summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--parse.y8
-rw-r--r--test/ruby/test_literal.rb10
3 files changed, 22 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 31236c15cc..6acd84265b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Nov 19 04:16:24 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (symbol_list): fix the node type of literal symbol list
+ with no interpolation. [ruby-core:66343]
+
Wed Nov 19 00:26:15 2014 Tanaka Akira <akr@fsij.org>
* tool/update-deps: Sort dependencies.
diff --git a/parse.y b/parse.y
index 861ff4945a..d8a07d06bf 100644
--- a/parse.y
+++ b/parse.y
@@ -4068,7 +4068,13 @@ symbol_list : /* none */
{
/*%%%*/
$2 = evstr2dstr($2);
- nd_set_type($2, NODE_DSYM);
+ if (nd_type($2) == NODE_DSTR) {
+ nd_set_type($2, NODE_DSYM);
+ }
+ else {
+ nd_set_type($2, NODE_LIT);
+ $2->nd_lit = rb_str_intern($2->nd_lit);
+ }
$$ = list_append($1, $2);
/*%
$$ = dispatch2(symbols_add, $1, $2);
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index 036be5f470..6c1123d38e 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -433,4 +433,14 @@ class TestRubyLiteral < Test::Unit::TestCase
}
end
+ def test_symbol_list
+ assert_equal([:foo, :bar], %i[foo bar])
+ assert_equal([:"\"foo"], %i["foo])
+
+ x = 10
+ assert_equal([:foo, :b10], %I[foo b#{x}])
+ assert_equal([:"\"foo10"], %I["foo#{x}])
+
+ assert_ruby_status(["--disable-gems", "--dump=parsetree"], "%I[foo bar]")
+ end
end