Project

General

Profile

Actions

Backport #9275

closed

Class.new(Hash)#reject warning is confusing and is issued in situations where I don't think it should be

Added by myronmarston (Myron Marston) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:59254]

Description

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 NEWS entry 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 on it or expose it as part of your public API (as end users may call #reject on it).

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r44359.
Myron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


hash.c: reduce warning

Actions #3

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: REQUIRED

And r44358.

Actions #4

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Description updated (diff)
Actions #5

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport21
  • Status changed from Closed to Assigned
  • Assignee set to naruse (Yui NARUSE)

Updated by naruse (Yui NARUSE) over 8 years ago

  • Status changed from Assigned to Closed

Applied in changeset r44683.


merge revision(s) 44358,44359,44360,44363: [Backport #9275]

    hash.c: reword

    * hash.c (HAS_EXTRA_STATES, rb_hash_reject): use words "extra states".
    * hash.c (HAS_EXTRA_STATES): warn extra states only when something
      differ.  [ruby-core:59254] [Bug #9275]
Actions

Also available in: Atom PDF