mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	merge revision(s) ff5e660340: [Backport #17015]
				
					
				
			Added `NODE_SPECIAL_EXCESSIVE_COMMA` info to `ARGS` of `RubyVM::AbstractSyntaxTree`.
This commit is contained in:
		
							parent
							
								
									3fef159f81
								
							
						
					
					
						commit
						dd4e51d84e
					
				
					 3 changed files with 19 additions and 2 deletions
				
			
		
							
								
								
									
										4
									
								
								ast.c
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								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));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue