зеркало из https://github.com/github/ruby.git
variable.c: show namespace
* variable.c (rb_const_set): show namespace in warning messages. [Feature #7190] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5cab66cbcf
Коммит
f77c97a8ca
|
@ -1,3 +1,8 @@
|
|||
Thu Nov 29 17:45:10 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* variable.c (rb_const_set): show namespace in warning messages.
|
||||
[Feature #7190]
|
||||
|
||||
Thu Nov 29 17:31:53 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* lib/rubygems.rb (Gem.load_yaml): return if Kernel#gem is not defined
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# -*- coding: us-ascii -*-
|
||||
require 'test/unit'
|
||||
|
||||
class TestConst < Test::Unit::TestCase
|
||||
|
@ -50,7 +51,7 @@ class TestConst < Test::Unit::TestCase
|
|||
c = Class.new
|
||||
c.const_set(:X, 1)
|
||||
assert_output(nil, <<-WARNING) {c.const_set(:X, 2)}
|
||||
#{__FILE__}:#{__LINE__-1}: warning: already initialized constant X
|
||||
#{__FILE__}:#{__LINE__-1}: warning: already initialized constant #{c}::X
|
||||
#{__FILE__}:#{__LINE__-3}: warning: previous definition of X was here
|
||||
WARNING
|
||||
end
|
||||
|
|
|
@ -2136,7 +2136,11 @@ rb_const_set(VALUE klass, ID id, VALUE val)
|
|||
else {
|
||||
const char *name = rb_id2name(id);
|
||||
visibility = ce->flag;
|
||||
rb_warn("already initialized constant %s", name);
|
||||
if (klass == rb_cObject)
|
||||
rb_warn("already initialized constant %s", name);
|
||||
else
|
||||
rb_warn("already initialized constant %s::%s",
|
||||
rb_class2name(klass), name);
|
||||
if (!NIL_P(ce->file) && ce->line) {
|
||||
rb_compile_warn(RSTRING_PTR(ce->file), ce->line,
|
||||
"previous definition of %s was here", name);
|
||||
|
|
Загрузка…
Ссылка в новой задаче