merge revision(s) 63696: [Backport #14853]

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/branches/ruby_2_4@64559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2018-08-27 13:48:53 +00:00
parent 7d9572819b
commit 4941bba3c8
3 changed files with 40 additions and 5 deletions

View file

@ -2304,6 +2304,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));
}