From 1b474b869ccc3e93335e5b7ad01513d58f1fe1a3 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 19 Jun 2018 08:15:52 +0000 Subject: variable.c: fix receiver on private constant * variable.c (rb_const_search): fix NameError :receiver attribute on private constant, should raise with the included module, not the ICLASS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- variable.c | 1 + 1 file changed, 1 insertion(+) (limited to 'variable.c') diff --git a/variable.c b/variable.c index cdc9efe954..ee842e5842 100644 --- a/variable.c +++ b/variable.c @@ -2362,6 +2362,7 @@ rb_const_search(VALUE klass, ID id, int exclude, int recurse, int visibility) while ((ce = rb_const_lookup(tmp, id))) { if (visibility && RB_CONST_PRIVATE_P(ce)) { + if (BUILTIN_TYPE(tmp) == T_ICLASS) tmp = RBASIC(tmp)->klass; rb_name_err_raise("private constant %2$s::%1$s referenced", tmp, ID2SYM(id)); } -- cgit v1.2.3