-
Notifications
You must be signed in to change notification settings - Fork 19
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
Check for easy-to-handle cases of block param #24
Conversation
In some cases, methods taking block parameters don't require extra paramter setup. They are fairly popular in railsbench.
iseq->body->param.flags.has_post == false && | ||
iseq->body->param.flags.has_kw == false && | ||
iseq->body->param.flags.has_kwrest == false && | ||
iseq->body->param.flags.accepts_no_kwarg == false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accepts_no_kwarg == false
means the method accepts kwargs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea. For example, calling methods that only take position arguments with keywords is allowed:
def foo(a)
p(a)
end
foo(key: 'word') # => {:key=>"word"}
We reject call kwarg call sites at the moment, though, just in case you are wondering how we deal with the kwargs to hash conversion.
The accepts_no_kwarg
flag is for the **nil
syntax:
def a(arg, **nil)
p(arg)
end
a(key: 'word') # no keywords accepted (ArgumentError)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will merge this but I think this is the sort of thing that could be better commented, because it's really not obvious for people not intimately familiar with specific parts of CRuby.
In some cases, methods taking block parameters don't require extra paramter setup. They are fairly popular in railsbench.
In some cases, methods taking block parameters don't require extra paramter setup. They are fairly popular in railsbench.
In some cases, methods taking block parameters don't require extra paramter setup. They are fairly popular in railsbench.
In some cases, methods taking block parameters don't require extra paramter setup. They are fairly popular in railsbench.
In some cases, methods taking block parameters don't require extra paramter setup. They are fairly popular in railsbench.
In some cases, methods taking block parameters don't require extra paramter setup. They are fairly popular in railsbench.
In some cases, methods taking block parameters don't require extra paramter setup. They are fairly popular in railsbench.
In some cases, methods taking block parameters don't require extra paramter setup. They are fairly popular in railsbench.
In some cases, methods taking block parameters don't require extra paramter setup. They are fairly popular in railsbench.
In some cases, methods taking block parameters don't require extra
paramter setup. They are fairly popular in railsbench.