Project

General

Profile

Actions

Bug #4179

closed

OpenStruct#method_missing handles #[]= wrongly

Added by caius (Caius Durling) almost 14 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
Backport:
[ruby-core:33792]

Description

=begin

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 you call OpenStruct#[]=, and then amended OpenStruct#method_missing to fix the bug. Patch attached with both test case (including a check that OpenStruct#[] raises a NoMethodError too) and the fix in it.
=end


Files

ostruct_square_bracket_equals.patch (977 Bytes) ostruct_square_bracket_equals.patch Test case for []= and [], and fix for []= bug caius (Caius Durling), 12/21/2010 08:40 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0