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
Do not allow memoization methods with nonzero arity #10
Conversation
This makes sure the memoizer is not used to create tricky to track down bugs.
Dunno how we will kill the mutation under 1.9 as soon mutant is able to mutate adamantium.
@dkubb Any problems with this? I'd like to get it merged. |
visibility = method_visibility(method) | ||
def memoize_method(method_name, freezer) | ||
method = instance_method(method_name) | ||
unless method.arity.zero? |
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.
You could also write this as if method.arity.nonzero?
which matches what you're testing a bit more closely.
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.
Also, since you're only using method
one time I would be more likely just to do it inline, eg:
if instance_method(method_name).arity.nonzero?
# ...
EDIT: oh wait, I see what you're doing now. nevermind. Does UnboundMethod#name
always know the original name?
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.
Yeah, it does always return the original name. https://github.com/rubyspec/rubyspec/blob/master/core/unboundmethod/name_spec.rb
@mbj I think you can merge this in if you change to use |
CI failed for external and IMHO temporal reason on one ruby https://travis-ci.org/dkubb/adamantium/builds/4056359 I'll merge anyways. This will trigger a new build that I predict to be green. |
Do not allow memoization methods with nonzero arity
@mbj when a single build fails you can always restart it by clicking on the icon in the upper-right that looks like a little gear.. click on "Restart Job". |
Thx. Im not a great GUI user ;). BTW I plan to add a rake task to devtools for this job. (Or a CLI task) |
This makes sure the memoizer is not used to create tricky to track down
bugs.
Currently adamantium allows the following: