Actions
Bug #11983
closeddefine_method not raising error for invalid method name
Bug #11983:
define_method not raising error for invalid method name
Description
Steps to Reproduce:¶
Inside irb:
Class A
end
A.send(:define_method, "may_run!?") do |*args, &block|
p "random text"
end
a = A.new
a.may_run!?
- never return from this function.
IF I try to declare this function using class_eval
A.class_eval <<-EQRUBY
def may_run!?
p 'some text'
end
EQRUBY
end
I got error: syntax error, unexpected '?', expecting ';' or '\n'.
I think class_eval behaviour is right because may_run!? is invalid name for method and define_method should raise error instead of defining it.
Actions