[前][次][番号順一覧][スレッド一覧]

ruby-changes:36403

From: nobu <ko1@a...>
Date: Wed, 19 Nov 2014 04:16:40 +0900 (JST)
Subject: [ruby-changes:36403] nobu:r48484 (trunk): parse.y: fix literal symbol list node type

nobu	2014-11-19 04:16:27 +0900 (Wed, 19 Nov 2014)

  New Revision: 48484

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48484

  Log:
    parse.y: fix literal symbol list node type
    
    * parse.y (symbol_list): fix the node type of literal symbol list
      with no interpolation.  [ruby-core:66343]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_literal.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48483)
+++ ChangeLog	(revision 48484)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Nov 19 04:16:24 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@f...>
 
 	* tool/update-deps: Sort dependencies.
Index: parse.y
===================================================================
--- parse.y	(revision 48483)
+++ parse.y	(revision 48484)
@@ -4068,7 +4068,13 @@ symbol_list	: /* none */ https://github.com/ruby/ruby/blob/trunk/parse.y#L4068
 		    {
 		    /*%%%*/
 			$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);
Index: test/ruby/test_literal.rb
===================================================================
--- test/ruby/test_literal.rb	(revision 48483)
+++ test/ruby/test_literal.rb	(revision 48484)
@@ -433,4 +433,14 @@ class TestRubyLiteral < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_literal.rb#L433
     }
   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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]