Skip to content

mattr_reader: protected method `[]' called for {}:Hash #13

@akicho8

Description

@akicho8

activesupport を利用しているライブラリで rake test すると転けるようになってしまい、原因を追ったところ、次のコードで再現できるところまで絞れました。

gem "power_assert", "0.2.5"
gem "activesupport", "4.2.4"

require "power_assert"
require "active_support/core_ext/module/attribute_accessors"
require "active_support/configurable"

module M
  mattr_reader :x
end
# ~> /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/core_ext/module/attribute_accessors.rb:65:in `block in mattr_reader': protected method `[]' called for {}:Hash (NoMethodError)
# ~>    from /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/core_ext/module/attribute_accessors.rb:55:in `each'
# ~>    from /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/core_ext/module/attribute_accessors.rb:55:in `mattr_reader'
# ~>    from -:9:in `<module:M>'
# ~>    from -:8:in `<main>'

わかっていること

  • 0.2.4 だと動く
  • require "active_support/configurable" を実行しないと動く
  • power_assert を active_support/configurable 後に require すると動く

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions