diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-15 15:40:10 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-15 15:40:10 +0000 |
commit | 13f618f1ed08ebe182c3bf2e4948fd3be2a2be3d (patch) | |
tree | 4e9d7b92591cd0a37d795ec8b7b60c24a5786767 | |
parent | ac9d6faafea77f24ce0de1d6c10c122cf6adb45a (diff) |
merge revision(s) 55005: [Backport #12382]
* vm_insnhelper.c (vm_get_ev_const): warn deprecated constant even
in the class context. [ruby-core:75505] [Bug #12382]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@55425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 2 | ||||
-rw-r--r-- | variable.c | 24 | ||||
-rw-r--r-- | version.h | 6 | ||||
-rw-r--r-- | vm_insnhelper.c | 2 |
5 files changed, 27 insertions, 12 deletions
@@ -1,3 +1,8 @@ +Thu Jun 16 00:29:29 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm_insnhelper.c (vm_get_ev_const): warn deprecated constant even + in the class context. [ruby-core:75505] [Bug #12382] + Tue Jun 14 03:49:28 2016 Eric Wong <e@80x24.org> * dir.c (dir_close): update RDoc for 2.3 #close change diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index e13f7e9110..1e5e5a428d 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1419,6 +1419,8 @@ class TestModule < Test::Unit::TestCase c.const_set(:FOO, "foo") c.deprecate_constant(:FOO) assert_warn(/deprecated/) {c::FOO} + bug12382 = '[ruby-core:75505] [Bug #12382]' + assert_warn(/deprecated/, bug12382) {c.class_eval "FOO"} end def test_constants_with_private_constant diff --git a/variable.c b/variable.c index 1f8506e784..1a18c379fd 100644 --- a/variable.c +++ b/variable.c @@ -2209,6 +2209,20 @@ rb_autoload_p(VALUE mod, ID id) return (ele = check_autoload_data(load)) ? ele->feature : Qnil; } +void +rb_const_warn_if_deprecated(const rb_const_entry_t *ce, VALUE klass, ID id) +{ + if (RB_CONST_DEPRECATED_P(ce)) { + if (klass == rb_cObject) { + rb_warn("constant ::%"PRIsVALUE" is deprecated", QUOTE_ID(id)); + } + else { + rb_warn("constant %"PRIsVALUE"::%"PRIsVALUE" is deprecated", + rb_class_name(klass), QUOTE_ID(id)); + } + } +} + static VALUE rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility) { @@ -2226,15 +2240,7 @@ rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility) rb_name_err_raise("private constant %2$s::%1$s referenced", klass, ID2SYM(id)); } - if (RB_CONST_DEPRECATED_P(ce)) { - if (klass == rb_cObject) { - rb_warn("constant ::%"PRIsVALUE" is deprecated", QUOTE_ID(id)); - } - else { - rb_warn("constant %"PRIsVALUE"::%"PRIsVALUE" is deprecated", - rb_class_name(klass), QUOTE_ID(id)); - } - } + rb_const_warn_if_deprecated(ce, klass, id); value = ce->value; if (value == Qundef) { if (am == tmp) break; @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.3.2" -#define RUBY_RELEASE_DATE "2016-06-14" -#define RUBY_PATCHLEVEL 130 +#define RUBY_RELEASE_DATE "2016-06-16" +#define RUBY_PATCHLEVEL 131 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 14 +#define RUBY_RELEASE_DAY 16 #include "ruby/version.h" diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 29bf2faab9..2f34530d04 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -660,6 +660,7 @@ vm_get_iclass(rb_control_frame_t *cfp, VALUE klass) static inline VALUE vm_get_ev_const(rb_thread_t *th, VALUE orig_klass, ID id, int is_defined) { + void rb_const_warn_if_deprecated(const rb_const_entry_t *ce, VALUE klass, ID id); VALUE val; if (orig_klass == Qnil) { @@ -686,6 +687,7 @@ vm_get_ev_const(rb_thread_t *th, VALUE orig_klass, ID id, int is_defined) rb_const_entry_t *ce; search_continue: if ((ce = rb_const_lookup(klass, id))) { + rb_const_warn_if_deprecated(ce, klass, id); val = ce->value; if (val == Qundef) { if (am == klass) break; |