diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-13 17:38:12 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-13 17:38:12 +0000 |
commit | d9bf8874825f26c82f8a099d429bc8c0934d5bc6 (patch) | |
tree | 7570ecd30255961f8eb7d50bf15b41d0e0715f25 /vm_method.c | |
parent | 57da247e430422a0a6d678522685caa3dbaed260 (diff) | |
download | ruby-d9bf8874825f26c82f8a099d429bc8c0934d5bc6.tar.gz |
* vm.c (vm_define_method): do not use current CREF immediately,
but check CREF in environment or methods. Methods defined in methods
should be public.
[Bug #11571]
* vm_method.c (rb_scope_module_func_check): check CREF in env or me.
if CREF is contained by `me', then return FALSE.
* test/ruby/test_method.rb: add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c index 6c2137b7b3..1bc499f1b5 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1045,7 +1045,15 @@ rb_scope_visibility_get(void) static int rb_scope_module_func_check(void) { - return CREF_SCOPE_VISI(rb_vm_cref())->module_func; + rb_thread_t *th = GET_THREAD(); + rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); + + if (!vm_env_cref_by_cref(cfp->ep)) { + return FALSE; + } + else { + return CREF_SCOPE_VISI(rb_vm_cref())->module_func; + } } static void |