-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
JRuby 2.2 mode inconsistent with MRI 2.1+ #3507
Comments
Surprising. This should just be a frame field that propagates to the define_method. |
Simpler repro: module Foo
module_function
define_method(:foo) {}
end
Foo.foo # error on JRuby, not on MRI |
I'm not sure this has worked for a long time. JRuby appears to always define_method as public as far back as 2011:
Going to look at improving this for 9.1, when we make a bigger move to 2.3 compatibility. |
Aww boo 😢 so no fix for 9.0.5.0 so we can stop doing extend self on modules? |
I added a spec for the private case with an UnboundMethod in d6b97fb. It would be good to have new specs for blocks and private and module_function visibility. |
@envygeeks You should be able to modify it to do module_function after the definition. It will work the same way as calling it once before a group of method definitions. |
The trivial fix (grabbing current frame's visibility) appears to regress a couple specs:
I don't think we're properly managing visibility yet. |
This also modifies main#define_method to always use public. I'm not sure this is the correct behavior, but it passes specs.
With a tweak to the "top self" |
As it stands JRuby 2.2 mode (on 9.0.3.0) is inconsistent with MRI 2.1+ when it comes to
module_function
anddefine_method
behavior. Take the following sample:In Ruby 2.0
module_function
is not inherited, but in 2.1+ it is inherited, this leads to inconsistent behavior when moving between JRuby and MRI.The text was updated successfully, but these errors were encountered: