diff options
| author | Satoshi Tagomori <s-tagomori@sakura.ad.jp> | 2025-06-22 17:38:24 +0900 |
|---|---|---|
| committer | Satoshi Tagomori <tagomoris@gmail.com> | 2025-09-29 01:15:38 +0900 |
| commit | 76c4663a77796fdcba539250dca3e6786ca0fd32 (patch) | |
| tree | 258c3aa8efc44c17ca4cddf902922cb142499638 /namespace.c | |
| parent | 4f47327287c00836a9826805a8799678d2c18516 (diff) | |
Fix Namespace.current to show its caller's namespace
Calling rb_current_namespace() in rb_namespace_current() means to show
the definition namespace of Namespace.current itself (it's the root always)
but the users' expectation is to show the namespace of the place where
the Namespace.current is called.
Diffstat (limited to 'namespace.c')
| -rw-r--r-- | namespace.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/namespace.c b/namespace.c index d3ac255363..65a90cb0da 100644 --- a/namespace.c +++ b/namespace.c @@ -455,11 +455,12 @@ rb_namespace_s_getenabled(VALUE namespace) static VALUE rb_namespace_current(VALUE klass) { - const rb_namespace_t *ns = rb_current_namespace(); + const rb_namespace_t *ns; if (!rb_namespace_available()) return Qnil; + ns = rb_vm_caller_namespace(GET_EC()); VM_ASSERT(ns && ns->ns_object); return ns->ns_object; } |
