Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node.c: fix nd_ainfo->kw_rest_arg #1529

Closed
wants to merge 1 commit into from
Closed

node.c: fix nd_ainfo->kw_rest_arg #1529

wants to merge 1 commit into from

Conversation

fate0
Copy link

@fate0 fate0 commented Feb 27, 2017

def foo1(a: 1, **kwrest)
end

old:

# @ NODE_SCOPE (line: 2)
# +- nd_tbl: (empty)
# +- nd_args:
# |   (null node)
# +- nd_body:
#     @ NODE_PRELUDE (line: 2)
#     +- nd_head:
#     |   (null node)
#     +- nd_body:
#     |   @ NODE_DEFN (line: 1)
#     |   +- nd_mid: :foo1
#     |   +- nd_defn:
#     |       @ NODE_SCOPE (line: 2)
#     |       +- nd_tbl: :a,(internal variable),:kwrest
#     |       +- nd_args:
#     |       |   @ NODE_ARGS (line: 1)
#     |       |   +- nd_ainfo->pre_args_num: 0
#     |       |   +- nd_ainfo->pre_init:
#     |       |   |   (null node)
#     |       |   +- nd_ainfo->post_args_num: 0
#     |       |   +- nd_ainfo->post_init:
#     |       |   |   (null node)
#     |       |   +- nd_ainfo->first_post_arg: (null)
#     |       |   +- nd_ainfo->rest_arg: (null)
#     |       |   +- nd_ainfo->block_arg: (null)
#     |       |   +- nd_ainfo->opt_args:
#     |       |   |   (null node)
#     |       |   +- nd_ainfo->kw_args:
#     |       |       @ NODE_KW_ARG (line: 1)
#     |       |       +- nd_body:
#     |       |       |   @ NODE_LASGN (line: 1)
#     |       |       |   +- nd_vid: :a
#     |       |       |   +- nd_value:
#     |       |       |       @ NODE_LIT (line: 1)
#     |       |       |       +- nd_lit: 1
#     |       |       +- nd_next:
#     |       |           (null node)
#     |       |   +- nd_ainfo->kw_rest_arg:
#     |       |       @ NODE_DVAR (line: 1)
#     |       |       +- nd_vid: (internal variable)
#     |       +- nd_body:
#     |           (null node)
#     +- nd_compile_option: false

if nd_ainfo->kw_args is not null, It should use nd_cflag

new

# @ NODE_SCOPE (line: 2)
# +- nd_tbl: (empty)
# +- nd_args:
# |   (null node)
# +- nd_body:
#     @ NODE_PRELUDE (line: 2)
#     +- nd_head:
#     |   (null node)
#     +- nd_body:
#     |   @ NODE_DEFN (line: 1)
#     |   +- nd_mid: :foo1
#     |   +- nd_defn:
#     |       @ NODE_SCOPE (line: 2)
#     |       +- nd_tbl: :a,(internal variable),:kwrest
#     |       +- nd_args:
#     |       |   @ NODE_ARGS (line: 1)
#     |       |   +- nd_ainfo->pre_args_num: 0
#     |       |   +- nd_ainfo->pre_init:
#     |       |   |   (null node)
#     |       |   +- nd_ainfo->post_args_num: 0
#     |       |   +- nd_ainfo->post_init:
#     |       |   |   (null node)
#     |       |   +- nd_ainfo->first_post_arg: (null)
#     |       |   +- nd_ainfo->rest_arg: (null)
#     |       |   +- nd_ainfo->block_arg: (null)
#     |       |   +- nd_ainfo->opt_args:
#     |       |   |   (null node)
#     |       |   +- nd_ainfo->kw_args:
#     |       |   |   @ NODE_KW_ARG (line: 1)
#     |       |   |   +- nd_body:
#     |       |   |   |   @ NODE_LASGN (line: 1)
#     |       |   |   |   +- nd_vid: :a
#     |       |   |   |   +- nd_value:
#     |       |   |   |       @ NODE_LIT (line: 1)
#     |       |   |   |       +- nd_lit: 1
#     |       |   |   +- nd_next:
#     |       |   |       (null node)
#     |       |   +- nd_ainfo->kw_rest_arg->nd_cflag: :kwrest
#     |       +- nd_body:
#     |           (null node)
#     +- nd_compile_option: false

@hsbt hsbt closed this in 9b1f2b0 Feb 27, 2017
@nobu
Copy link
Member

nobu commented Feb 27, 2017

Oops, I missed the comment in 6d3654d!

matzbot pushed a commit that referenced this pull request Feb 16, 2018
	kwrest arg name

	* compile.c (iseq_set_arguments_keywords): make keyword rest
	  argument name nd_vid consistently, regardless of whether other
	  keyword arguments are present.  [Fix GH-1529]

	* parse.y (new_args_tail_gen): ditto.

	fix nd_ainfo->kw_rest_arg

	[Fix GH-5129]
	Author:    fate0 <fate0@users.noreply.github.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants