Project

General

Profile

Backport #9275

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

=begin 
 Consider this script: 

 ``` 
 

  $VERBOSE = true 
 
  Class.new(Hash).new.reject { } 
 ``` 

 When I run this with 2.1.0-rc1, I get the following output: 

 ``` 
 

  foo.rb:2: warning: copying unguaranteed attributes: {} 
 
  foo.rb:2: warning: following atributes will not be copied in the future version: 
 
  foo.rb:2: warning:     subclass: #<Class:0x007f91bb89dda8> 
 ``` 

 This warning is confusing.    I've been using ruby full time for ~ 5 years and I have no idea what "unguaranteed attributes" means.    In addition, I don't think this warning should be issued in this case at all.    According to [the ((<the NEWS entry](https://github.com/ruby/ruby/blob/9881a183bde20d1c174d33d8a2f637e9c092a08b/NEWS#L136-L141) entry|URL:https://github.com/ruby/ruby/blob/9881a183bde20d1c174d33d8a2f637e9c092a08b/NEWS#L136-L141>)) and #9223, this warning is intended for cases where there is extra state (instance variables, default proc, etc) that will not be copied in the future...but in this case, it's a subclass of Hash with no extra state or behavior.    Why should it warn in this case? 

 As things stand now, if you want to have a warning-free gem, you can no longer subclass hash if you call #`reject` #reject on it or expose it as part of your public API (as end users may call #`reject` #reject on it). 
 =end

Back