Issue #12382 has been reported by Jan Lelis.

----------------------------------------
Bug #12382: Deprecated constants will not print out warning when accessed directly
https://bugs.ruby-lang.org/issues/12382

* Author: Jan Lelis
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
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.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>