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

ruby-changes:54604

From: nobu <ko1@a...>
Date: Mon, 14 Jan 2019 19:16:58 +0900 (JST)
Subject: [ruby-changes:54604] nobu:r66819 (trunk): ast.c: fix missing head part in dynamic literal

nobu	2019-01-14 19:16:54 +0900 (Mon, 14 Jan 2019)

  New Revision: 66819

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

  Log:
    ast.c: fix missing head part in dynamic literal

  Modified files:
    trunk/ast.c
    trunk/test/ruby/test_ast.rb
Index: test/ruby/test_ast.rb
===================================================================
--- test/ruby/test_ast.rb	(revision 66818)
+++ test/ruby/test_ast.rb	(revision 66819)
@@ -266,4 +266,16 @@ class TestAst < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_ast.rb#L266
     assert_equal(:VCALL, recv.type)
     assert_equal(:foo, mid)
   end
+
+  def test_dstr
+    node = RubyVM::AbstractSyntaxTree.parse('"foo#{1}bar"')
+    _, _, body = *node.children
+    assert_equal(:DSTR, body.type)
+    head, body = body.children
+    assert_equal("foo", head)
+    assert_equal(:EVSTR, body.type)
+    body, = body.children
+    assert_equal(:LIT, body.type)
+    assert_equal([1], body.children)
+  end
 end
Index: ast.c
===================================================================
--- ast.c	(revision 66818)
+++ ast.c	(revision 66819)
@@ -528,7 +528,9 @@ node_children(rb_ast_t *ast, NODE *node) https://github.com/ruby/ruby/blob/trunk/ast.c#L528
         goto dlit;
       case NODE_DSYM:
       dlit:
-        return rb_ary_new_from_node_args(ast, 2, node->nd_next->nd_head, node->nd_next->nd_next);
+        return rb_ary_new_from_args(3, node->nd_lit,
+                                    NEW_CHILD(ast, node->nd_next->nd_head),
+                                    NEW_CHILD(ast, node->nd_next->nd_next));
       case NODE_EVSTR:
         return rb_ary_new_from_node_args(ast, 1, node->nd_body);
       case NODE_ARGSCAT:

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

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