mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ast.c: fix missing head part in dynamic literal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ec3cdb34ce
commit
4d727639b4
2 changed files with 15 additions and 1 deletions
4
ast.c
4
ast.c
|
@ -528,7 +528,9 @@ node_children(rb_ast_t *ast, NODE *node)
|
|||
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:
|
||||
|
|
|
@ -266,4 +266,16 @@ class TestAst < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue