summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2020-09-06 11:16:29 +0900
committernagachika <nagachika@ruby-lang.org>2020-09-06 11:16:29 +0900
commitdd4e51d84e01d9c60458dfe19a0b4d4e05b55140 (patch)
tree733bc60a72f9a9c8945bb6d50960322c4cf74059
parent3fef159f81fad6ffb9af5b60f4c8ec867fdb2391 (diff)
merge revision(s) ff5e66034006a875125581114cce19d46843b32a: [Backport #17015]
Added `NODE_SPECIAL_EXCESSIVE_COMMA` info to `ARGS` of `RubyVM::AbstractSyntaxTree`.
-rw-r--r--ast.c4
-rw-r--r--test/ruby/test_ast.rb15
-rw-r--r--version.h2
3 files changed, 19 insertions, 2 deletions
diff --git a/ast.c b/ast.c
index 79d8b12501..a0c026229c 100644
--- a/ast.c
+++ b/ast.c
@@ -570,7 +570,9 @@ node_children(rb_ast_t *ast, NODE *node)
var_name(ainfo->first_post_arg),
INT2NUM(ainfo->post_args_num),
NEW_CHILD(ast, ainfo->post_init),
- var_name(ainfo->rest_arg),
+ (ainfo->rest_arg == NODE_SPECIAL_EXCESSIVE_COMMA
+ ? ID2SYM(rb_intern("NODE_SPECIAL_EXCESSIVE_COMMA"))
+ : var_name(ainfo->rest_arg)),
(ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast, ainfo->kw_args)),
(ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast, ainfo->kw_rest_arg)),
var_name(ainfo->block_arg));
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb
index da7dde4a38..0d846b76e4 100644
--- a/test/ruby/test_ast.rb
+++ b/test/ruby/test_ast.rb
@@ -330,4 +330,19 @@ class TestAst < Test::Unit::TestCase
assert_equal(:+, op)
assert_equal(:VCALL, value.type)
end
+
+ def test_args
+ rest = 6
+ node = RubyVM::AbstractSyntaxTree.parse("proc { |a| }")
+ _, args = *node.children.last.children[1].children
+ assert_equal(nil, args.children[rest])
+
+ node = RubyVM::AbstractSyntaxTree.parse("proc { |a,| }")
+ _, args = *node.children.last.children[1].children
+ assert_equal(:NODE_SPECIAL_EXCESSIVE_COMMA, args.children[rest])
+
+ node = RubyVM::AbstractSyntaxTree.parse("proc { |*a| }")
+ _, args = *node.children.last.children[1].children
+ assert_equal(:a, args.children[rest])
+ end
end
diff --git a/version.h b/version.h
index eb34c6df10..dcdeec6d81 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 121
+#define RUBY_PATCHLEVEL 122
#define RUBY_RELEASE_YEAR 2020
#define RUBY_RELEASE_MONTH 9