Project

General

Profile

Bug #15515 ยป 0001-ostruct.rb-refine-arity-failure-message.patch

lugray (Lisa Ugray), 01/07/2019 01:19 PM

View differences:

lib/ostruct.rb
213 213
    len = args.length
214 214
    if mname = mid[/.*(?==\z)/m]
215 215
      if len != 1
216
        raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
216
        raise ArgumentError, "wrong number of arguments (given #{len}, expected 1)", caller(1)
217 217
      end
218 218
      modifiable?[new_ostruct_member!(mname)] = args[0]
219
    elsif len == 0 # and /\A[a-z_]\w*\z/ =~ mid #
220
      if @table.key?(mid)
221
        new_ostruct_member!(mid) unless frozen?
222
        @table[mid]
219
    elsif @table.key?(mid)
220
      if len != 0
221
        raise ArgumentError, "wrong number of arguments (given #{len}, expected 0)"
223 222
      end
223
      new_ostruct_member!(mid) unless frozen?
224
      @table[mid]
224 225
    else
225 226
      begin
226 227
        super