Project

General

Profile

Bug #14469

private_constant and deprecate_constant are ignored by autoloading

Added by nobu (Nobuyoshi Nakada) 3 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
2.0 or later
[ruby-core:85516]

Description

Consider the following code in file "zzz.rb":

class ZZZ
  P = D = 1
  private_constant :P
  deprecate_constant :D
end

After loading the file, accesses to ZZZ::P and ZZZ:D cause an exception and a warning respectively.

$ ruby -r./zzz -e ZZZ::P
Traceback (most recent call last):
-e:1:in `<main>': private constant ZZZ::P referenced (NameError)
$ ruby -r./zzz -e ZZZ::D
-e:1: warning: constant ZZZ::D is deprecated

But autoloading the file nothing happens.

$ ruby -e 'class ZZZ;autoload :P,"./zzz.rb";end; ZZZ::P'
$ ruby -e 'class ZZZ;autoload :D,"./zzz.rb";end; ZZZ::D'

After requiring the file in ordinary way, they works.

$ ruby -e 'class ZZZ;autoload :P,"./zzz.rb";end; require "./zzz.rb"; ZZZ::P'
Traceback (most recent call last):
-e:1:in `<main>': private constant ZZZ::P referenced (NameError)
$ ruby -e 'class ZZZ;autoload :D,"./zzz.rb";end; require "./zzz.rb"; ZZZ::D'
-e:1: warning: constant ZZZ::D is deprecated

Associated revisions

Revision a6a596a5
Added by nobu (Nobuyoshi Nakada) 3 months ago

variable.c: flags at autoloading

  • variable.c (const_tbl_update): flags by deprecate_constant / private_constant set during autoloading should be preserved after required. [Bug #14469]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62392
Added by nobu (Nobuyoshi Nakada) 3 months ago

variable.c: flags at autoloading

  • variable.c (const_tbl_update): flags by deprecate_constant / private_constant set during autoloading should be preserved after required. [Bug #14469]

Revision 8cdac548
Added by nobu (Nobuyoshi Nakada) 3 months ago

vm_insnhelper.c: rb_autoloading_value flag

  • vm_insnhelper.c (vm_get_ev_const): add flag argument of
    rb_autoloading_value.

  • constant.h (rb_autoloading_value): moved the declaration from
    vm_core.h for rb_const_flag_t. [Bug #14469]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62394
Added by nobu (Nobuyoshi Nakada) 3 months ago

vm_insnhelper.c: rb_autoloading_value flag

  • vm_insnhelper.c (vm_get_ev_const): add flag argument of
    rb_autoloading_value.

  • constant.h (rb_autoloading_value): moved the declaration from
    vm_core.h for rb_const_flag_t. [Bug #14469]

Revision 248ff4f1
Added by nobu (Nobuyoshi Nakada) 3 months ago

variable.c: flags at autoloading

  • variable.c (const_tbl_update): flags by deprecate_constant / private_constant set during autoloading should be preserved after required. [Bug #14469]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62395
Added by nobu (Nobuyoshi Nakada) 3 months ago

variable.c: flags at autoloading

  • variable.c (const_tbl_update): flags by deprecate_constant / private_constant set during autoloading should be preserved after required. [Bug #14469]

Revision d11ce2be
Added by naruse (Yui NARUSE) 2 months ago

merge revision(s) 62394,62395: [Backport #14469]

vm_insnhelper.c: rb_autoloading_value flag

* vm_insnhelper.c (vm_get_ev_const): add flag argument of
  `rb_autoloading_value`.

* constant.h (rb_autoloading_value): moved the declaration from
  vm_core.h for `rb_const_flag_t`.   [Bug #14469]

variable.c: flags at autoloading

* variable.c (const_tbl_update): flags by deprecate_constant /
  private_constant set during autoloading should be preserved
  after required.   [Bug #14469]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62761
Added by naruse (Yui NARUSE) 2 months ago

merge revision(s) 62394,62395: [Backport #14469]

vm_insnhelper.c: rb_autoloading_value flag

* vm_insnhelper.c (vm_get_ev_const): add flag argument of
  `rb_autoloading_value`.

* constant.h (rb_autoloading_value): moved the declaration from
  vm_core.h for `rb_const_flag_t`.   [Bug #14469]

variable.c: flags at autoloading

* variable.c (const_tbl_update): flags by deprecate_constant /
  private_constant set during autoloading should be preserved
  after required.   [Bug #14469]

Revision 9869b655
Added by nagachika (Tomoyuki Chikanaga) 2 months ago

merge revision(s) 62394,62395: [Backport #14469]

vm_insnhelper.c: rb_autoloading_value flag

* vm_insnhelper.c (vm_get_ev_const): add flag argument of
  `rb_autoloading_value`.

* constant.h (rb_autoloading_value): moved the declaration from
  vm_core.h for `rb_const_flag_t`.   [Bug #14469]

variable.c: flags at autoloading

* variable.c (const_tbl_update): flags by deprecate_constant /
  private_constant set during autoloading should be preserved
  after required.   [Bug #14469]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62916
Added by nagachika (Tomoyuki Chikanaga) 2 months ago

merge revision(s) 62394,62395: [Backport #14469]

vm_insnhelper.c: rb_autoloading_value flag

* vm_insnhelper.c (vm_get_ev_const): add flag argument of
  `rb_autoloading_value`.

* constant.h (rb_autoloading_value): moved the declaration from
  vm_core.h for `rb_const_flag_t`.   [Bug #14469]

variable.c: flags at autoloading

* variable.c (const_tbl_update): flags by deprecate_constant /
  private_constant set during autoloading should be preserved
  after required.   [Bug #14469]

History

#1 Updated by nobu (Nobuyoshi Nakada) 3 months ago

  • Status changed from Open to Closed

Applied in changeset trunk|r62392.


variable.c: flags at autoloading

  • variable.c (const_tbl_update): flags by deprecate_constant / private_constant set during autoloading should be preserved after required. [Bug #14469]

#2 [ruby-core:86129] Updated by naruse (Yui NARUSE) 2 months ago

  • Backport changed from 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED to 2.3: REQUIRED, 2.4: REQUIRED, 2.5: DONE

ruby_2_5 r62761 merged revision(s) 62394,62395.

#3 [ruby-core:86287] Updated by nagachika (Tomoyuki Chikanaga) 2 months ago

  • Backport changed from 2.3: REQUIRED, 2.4: REQUIRED, 2.5: DONE to 2.3: REQUIRED, 2.4: DONE, 2.5: DONE

ruby_2_4 r62916 merged revision(s) 62394,62395.

Also available in: Atom PDF