ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:90918] [Ruby trunk Bug#15515] OpenStruct raising NoMethodError instead of ArgumentError
       [not found] <redmine.issue-15515.20190107134140@ruby-lang.org>
@ 2019-01-07 13:41 ` lisa.ugray
  2019-01-07 16:14 ` [ruby-core:90919] " nardonykolyszyn
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: lisa.ugray @ 2019-01-07 13:41 UTC (permalink / raw)
  To: ruby-core

Issue #15515 has been reported by lugray (Lisa Ugray).

----------------------------------------
Bug #15515: OpenStruct raising NoMethodError instead of ArgumentError
https://bugs.ruby-lang.org/issues/15515

* Author: lugray (Lisa Ugray)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-01-07 trunk 66747) [x86_64-darwin18]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
When an `OpenStruct` has some attribute `foo`, calling the `foo` method with an argument gives a no method error:
```ruby
foo = OpenStuct.new(bar: 'baz')
foo.bar(0) # => NoMethodError (undefined method `bar' for #<OpenStruct bar="baz">)
```

This is confusing, since `foo.respond_to?(:bar) # => true`. I would expect:
```ruby
foo = OpenStuct.new(bar: 'baz')
foo.bar(0) # => ArgumentError (wrong number of arguments (given 1, expected 0))
```

The included fixes this, and adjusts the arity `ArgumentError` for the setter to be in line with the default arity messaging too.

---Files--------------------------------
0001-ostruct.rb-refine-arity-failure-message.patch (1.26 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:90919] [Ruby trunk Bug#15515] OpenStruct raising NoMethodError instead of ArgumentError
       [not found] <redmine.issue-15515.20190107134140@ruby-lang.org>
  2019-01-07 13:41 ` [ruby-core:90918] [Ruby trunk Bug#15515] OpenStruct raising NoMethodError instead of ArgumentError lisa.ugray
@ 2019-01-07 16:14 ` nardonykolyszyn
  2019-01-07 16:21 ` [ruby-core:90920] " nardonykolyszyn
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: nardonykolyszyn @ 2019-01-07 16:14 UTC (permalink / raw)
  To: ruby-core

Issue #15515 has been updated by devpolish (Nardo Nykolyszyn).


Did you mean?  OpenStruct

----------------------------------------
Bug #15515: OpenStruct raising NoMethodError instead of ArgumentError
https://bugs.ruby-lang.org/issues/15515#change-76111

* Author: lugray (Lisa Ugray)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-01-07 trunk 66747) [x86_64-darwin18]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
When an `OpenStruct` has some attribute `foo`, calling the `foo` method with an argument gives a no method error:
```ruby
foo = OpenStuct.new(bar: 'baz')
foo.bar(0) # => NoMethodError (undefined method `bar' for #<OpenStruct bar="baz">)
```

This is confusing, since `foo.respond_to?(:bar) # => true`. I would expect:
```ruby
foo = OpenStuct.new(bar: 'baz')
foo.bar(0) # => ArgumentError (wrong number of arguments (given 1, expected 0))
```

The included fixes this, and adjusts the arity `ArgumentError` for the setter to be in line with the default arity messaging too.

---Files--------------------------------
0001-ostruct.rb-refine-arity-failure-message.patch (1.26 KB)
0001-ostruct.rb-refine-arity-failure-message.patch (1.96 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:90920] [Ruby trunk Bug#15515] OpenStruct raising NoMethodError instead of ArgumentError
       [not found] <redmine.issue-15515.20190107134140@ruby-lang.org>
  2019-01-07 13:41 ` [ruby-core:90918] [Ruby trunk Bug#15515] OpenStruct raising NoMethodError instead of ArgumentError lisa.ugray
  2019-01-07 16:14 ` [ruby-core:90919] " nardonykolyszyn
@ 2019-01-07 16:21 ` nardonykolyszyn
  2019-01-07 16:26 ` [ruby-core:90921] " lisa.ugray
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: nardonykolyszyn @ 2019-01-07 16:21 UTC (permalink / raw)
  To: ruby-core

Issue #15515 has been updated by devpolish (Nardo Nykolyszyn).


I can't understand why you're trying to pass an argument to a String object, OpenStruct creates attr_reader and attr_accessor based in your keys.

$ foo.methods false # => [:instance_methods, :instance_methods=, :bar, :bar=]
$foo.bar.class # => String

So, basically you're calling a reader method inside your OpenStruct object which's telling you that doesn't accept any argument, seems totally clear for me.

----------------------------------------
Bug #15515: OpenStruct raising NoMethodError instead of ArgumentError
https://bugs.ruby-lang.org/issues/15515#change-76112

* Author: lugray (Lisa Ugray)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-01-07 trunk 66747) [x86_64-darwin18]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
When an `OpenStruct` has some attribute `foo`, calling the `foo` method with an argument gives a no method error:
```ruby
foo = OpenStuct.new(bar: 'baz')
foo.bar(0) # => NoMethodError (undefined method `bar' for #<OpenStruct bar="baz">)
```

This is confusing, since `foo.respond_to?(:bar) # => true`. I would expect:
```ruby
foo = OpenStuct.new(bar: 'baz')
foo.bar(0) # => ArgumentError (wrong number of arguments (given 1, expected 0))
```

The included fixes this, and adjusts the arity `ArgumentError` for the setter to be in line with the default arity messaging too.

---Files--------------------------------
0001-ostruct.rb-refine-arity-failure-message.patch (1.26 KB)
0001-ostruct.rb-refine-arity-failure-message.patch (1.96 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:90921] [Ruby trunk Bug#15515] OpenStruct raising NoMethodError instead of ArgumentError
       [not found] <redmine.issue-15515.20190107134140@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-01-07 16:21 ` [ruby-core:90920] " nardonykolyszyn
@ 2019-01-07 16:26 ` lisa.ugray
  2019-04-12 22:42 ` [ruby-core:92266] " ruby-core
  2019-04-14 13:50 ` [ruby-core:92282] " ruby-core
  5 siblings, 0 replies; 6+ messages in thread
From: lisa.ugray @ 2019-01-07 16:26 UTC (permalink / raw)
  To: ruby-core

Issue #15515 has been updated by lugray (Lisa Ugray).


devpolish (Nardo Nykolyszyn) wrote:
> Did you mean?  OpenStruct

Yes, thanks, fixed.

----------------------------------------
Bug #15515: OpenStruct raising NoMethodError instead of ArgumentError
https://bugs.ruby-lang.org/issues/15515#change-76114

* Author: lugray (Lisa Ugray)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-01-07 trunk 66747) [x86_64-darwin18]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
When an `OpenStruct` has some attribute `foo`, calling the `foo` method with an argument gives a no method error:
```ruby
foo = OpenStruct.new(bar: 'baz')
foo.bar(0) # => NoMethodError (undefined method `bar' for #<OpenStruct bar="baz">)
```

This is confusing, since `foo.respond_to?(:bar) # => true`. I would expect:
```ruby
foo = OpenStruct.new(bar: 'baz')
foo.bar(0) # => ArgumentError (wrong number of arguments (given 1, expected 0))
```

The included fixes this, and adjusts the arity `ArgumentError` for the setter to be in line with the default arity messaging too.

---Files--------------------------------
0001-ostruct.rb-refine-arity-failure-message.patch (1.26 KB)
0001-ostruct.rb-refine-arity-failure-message.patch (1.96 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:92266] [Ruby trunk Bug#15515] OpenStruct raising NoMethodError instead of ArgumentError
       [not found] <redmine.issue-15515.20190107134140@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2019-01-07 16:26 ` [ruby-core:90921] " lisa.ugray
@ 2019-04-12 22:42 ` ruby-core
  2019-04-14 13:50 ` [ruby-core:92282] " ruby-core
  5 siblings, 0 replies; 6+ messages in thread
From: ruby-core @ 2019-04-12 22:42 UTC (permalink / raw)
  To: ruby-core

Issue #15515 has been updated by marcandre (Marc-Andre Lafortune).

Assignee set to marcandre (Marc-Andre Lafortune)

Sorry I missed this.

I'm positive on this patch and will commit it shortly unless there's any objection.

----------------------------------------
Bug #15515: OpenStruct raising NoMethodError instead of ArgumentError
https://bugs.ruby-lang.org/issues/15515#change-77599

* Author: lugray (Lisa Ugray)
* Status: Open
* Priority: Normal
* Assignee: marcandre (Marc-Andre Lafortune)
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-01-07 trunk 66747) [x86_64-darwin18]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
When an `OpenStruct` has some attribute `foo`, calling the `foo` method with an argument gives a no method error:
```ruby
foo = OpenStruct.new(bar: 'baz')
foo.bar(0) # => NoMethodError (undefined method `bar' for #<OpenStruct bar="baz">)
```

This is confusing, since `foo.respond_to?(:bar) # => true`. I would expect:
```ruby
foo = OpenStruct.new(bar: 'baz')
foo.bar(0) # => ArgumentError (wrong number of arguments (given 1, expected 0))
```

The included fixes this, and adjusts the arity `ArgumentError` for the setter to be in line with the default arity messaging too.

---Files--------------------------------
0001-ostruct.rb-refine-arity-failure-message.patch (1.26 KB)
0001-ostruct.rb-refine-arity-failure-message.patch (1.96 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:92282] [Ruby trunk Bug#15515] OpenStruct raising NoMethodError instead of ArgumentError
       [not found] <redmine.issue-15515.20190107134140@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2019-04-12 22:42 ` [ruby-core:92266] " ruby-core
@ 2019-04-14 13:50 ` ruby-core
  5 siblings, 0 replies; 6+ messages in thread
From: ruby-core @ 2019-04-14 13:50 UTC (permalink / raw)
  To: ruby-core

Issue #15515 has been updated by marcandre (Marc-Andre Lafortune).

Status changed from Open to Closed

Merged. Thank you for your contribution!

----------------------------------------
Bug #15515: OpenStruct raising NoMethodError instead of ArgumentError
https://bugs.ruby-lang.org/issues/15515#change-77617

* Author: lugray (Lisa Ugray)
* Status: Closed
* Priority: Normal
* Assignee: marcandre (Marc-Andre Lafortune)
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-01-07 trunk 66747) [x86_64-darwin18]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
When an `OpenStruct` has some attribute `foo`, calling the `foo` method with an argument gives a no method error:
```ruby
foo = OpenStruct.new(bar: 'baz')
foo.bar(0) # => NoMethodError (undefined method `bar' for #<OpenStruct bar="baz">)
```

This is confusing, since `foo.respond_to?(:bar) # => true`. I would expect:
```ruby
foo = OpenStruct.new(bar: 'baz')
foo.bar(0) # => ArgumentError (wrong number of arguments (given 1, expected 0))
```

The included fixes this, and adjusts the arity `ArgumentError` for the setter to be in line with the default arity messaging too.

---Files--------------------------------
0001-ostruct.rb-refine-arity-failure-message.patch (1.26 KB)
0001-ostruct.rb-refine-arity-failure-message.patch (1.96 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-14 13:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-15515.20190107134140@ruby-lang.org>
2019-01-07 13:41 ` [ruby-core:90918] [Ruby trunk Bug#15515] OpenStruct raising NoMethodError instead of ArgumentError lisa.ugray
2019-01-07 16:14 ` [ruby-core:90919] " nardonykolyszyn
2019-01-07 16:21 ` [ruby-core:90920] " nardonykolyszyn
2019-01-07 16:26 ` [ruby-core:90921] " lisa.ugray
2019-04-12 22:42 ` [ruby-core:92266] " ruby-core
2019-04-14 13:50 ` [ruby-core:92282] " ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).