OpenStruct#respond_to? when true fails with NameError
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Reproduce the FakeDep example against the OpenStruct implementation at ostruct.rb around line 245, then read the linked commit to understand the method! and owner logic. Compare the observed NameError with the intended respond_to? behavior; done means establishing whether this is a supported bug and identifying the regression coverage or behavior change needed.
Written by the indexing model from the issue text.
Description
Hello,
I have a case where I overrode respond_to? on a subclass of OpenStruct because I this class to work as fake object.
class Dep
def a
"Hello from Dep"
end
end
class FakeDep < OpenStruct
def respond_to?(*args)
super || Dep.new.respond_to?(*args)
end
end
FakeDep.new(a: []) #=> NameError: undefined method `a' for class `FakeDep'
owner = method!(name).owner
^^^^^^^
from /usr/local/lib/ruby/3.1.0/ostruct.rb:245:in `method'
I didn't fully understand https://github.com/ruby/ruby/commit/f48edc28dda3df962f289fd373c06a8dfeda3dc0 and what happens with owner = method!(name).owner. Is the error above a valid case?
TIA
- Dominant language
- Ruby
- Stars
- 175
- Forks
- 35
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby/ostruct
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100