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
len = args.length
if mname = mid[/.*(?==\z)/m]
if len != 1
raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
raise ArgumentError, "wrong number of arguments (given #{len}, expected 1)", caller(1)
end
modifiable?[new_ostruct_member!(mname)] = args[0]
elsif len == 0 # and /\A[a-z_]\w*\z/ =~ mid #
if @table.key?(mid)
new_ostruct_member!(mid) unless frozen?
@table[mid]
elsif @table.key?(mid)
if len != 0
raise ArgumentError, "wrong number of arguments (given #{len}, expected 0)"
end
new_ostruct_member!(mid) unless frozen?
@table[mid]
else
begin
super
(1-1/2)