From 3f23ee7015448fbc33515dd8168c7b4d370c26e4 Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 28 Nov 2014 07:37:22 +0000 Subject: [PATCH] merge revision(s) 48484: [Backport #10524] * parse.y (symbol_list): fix the node type of literal symbol list with no interpolation. [ruby-core:66343] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@48635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ parse.y | 8 +++++++- test/ruby/test_literal.rb | 10 ++++++++++ version.h | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc69fda1bc..1cf823f31e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Nov 28 16:36:34 2014 Nobuyoshi Nakada + + * parse.y (symbol_list): fix the node type of literal symbol list + with no interpolation. [ruby-core:66343] + Fri Nov 28 16:28:07 2014 Nobuyoshi Nakada * ext/etc/etc.c (etc_getlogin): set login name encoding properly. diff --git a/parse.y b/parse.y index 00b1a4cba9..7484f4e53b 100644 --- a/parse.y +++ b/parse.y @@ -4043,7 +4043,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 e4c35e03d9..5fa326acfe 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -434,4 +434,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 diff --git a/version.h b/version.h index 4316f56001..c506ac8f5c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2014-11-28" -#define RUBY_PATCHLEVEL 604 +#define RUBY_PATCHLEVEL 605 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 11