Project

General

Profile

Actions

Bug #12382

closed

Deprecated constants will not print out warning when accessed directly

Added by rbjl (Jan Lelis) almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
[ruby-core:75505]

Description

Hi,

the current behavior of deprecate_constant is a little confusing:

module Namespace
  module Deprecated
  end

  deprecate_constant :Deprecated
end

puts "Referenced access:"
Namespace::Deprecated # warning: constant Namespace::Deprecated is deprecated

puts
puts "Direct access (from Object):"
include Namespace
Deprecated # warning: constant ::Deprecated is deprecated

puts
puts "Direct access (from inside namespace):"
module Namespace
  Deprecated # no warning
end

I would also expect a warning in the third case.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0