--mimepart_4d0fe986c56dd_3340b54eb007a1
Content-Type: text/plain
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

Bug #4179: OpenStruct#method_missing handles #[]= wrongly
http://redmine.ruby-lang.org/issues/show/4179

Author: Caius Durling
Status: Open, Priority: Normal
Category: lib, Target version: Ruby 1.8.7
ruby -v: ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] ## Code to reproduce:

    require "ostruct"
    OpenStruct.new[:foo] = true

## Expected

`NoMethodError` to be raised, as `OpenStruct#[]=` is not a defined method.

## Actual

`wrong number of arguments (2 for 1) (ArgumentError)`

## Notes

I wrote a test case to check that it would raise `NoMethodError` when youall `OpenStruct#[]=`, and then amended `OpenStruct#method_missing` toix the bug. Patch attached with both test case (including a check that `OpenStruct#[]` raises a `NoMethodError` too) and the fix in it.


----------------------------------------
http://redmine.ruby-lang.org

--mimepart_4d0fe986c56dd_3340b54eb007a1
Content-Type: text/plain; name=ostruct_square_bracket_equals.patch
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename=ostruct_square_bracket_equals.patch

ZGlmZiAtLWdpdCBhL2xpYi9vc3RydWN0LnJiIGIvbGliL29zdHJ1Y3QucmIK
aW5kZXggNDVlYmI4MC4uYjFhZDExNiAxMDA2NDQKLS0tIGEvbGliL29zdHJ1
Y3QucmIKKysrIGIvbGliL29zdHJ1Y3QucmIKQEAgLTg5LDcgKzg5LDcgQEAg
Y2xhc3MgT3BlblN0cnVjdAogICBkZWYgbWV0aG9kX21pc3NpbmcobWlkLCAq
YXJncykgIyA6bm9kb2M6CiAgICAgbW5hbWUgPSBtaWQuaWQybmFtZQogICAg
IGxlbiA9IGFyZ3MubGVuZ3RoCi0gICAgaWYgbW5hbWUuY2hvbXAhKCc9JykK
KyAgICBpZiBtbmFtZS5jaG9tcCEoJz0nKSAmJiBtbmFtZSAhPSAiW10iCiAg
ICAgICBpZiBsZW4gIT0gMQogICAgICAgICByYWlzZSBBcmd1bWVudEVycm9y
LCAid3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