[ruby-core:113352] [Ruby master Bug#19619] Endless method definition with parameters for an instance given as numbered parameters doesn't work
From:
"okuramasafumi (Masafumi OKURA) via ruby-core" <ruby-core@...>
Date:
2023-04-26 17:32:00 UTC
List:
ruby-core #113352
Issue #19619 has been reported by okuramasafumi (Masafumi OKURA).
----------------------------------------
Bug #19619: Endless method definition with parameters for an instance given as numbered parameters doesn't work
https://bugs.ruby-lang.org/issues/19619
* Author: okuramasafumi (Masafumi OKURA)
* Status: Open
* Priority: Normal
* ruby -v: 3.2.2
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
This works:
```ruby
class Foo
def bar(baz) = 'foo'
end
p Foo.new.bar('baz')
```
This also works:
```ruby
o = Object.new
o.tap { |obj| def obj.bar(baz) = 'foo' }
p o.bar('baz')
```
Even this works:
```ruby
o = Object.new
o.tap { def _1.bar = 'foo' }
p o.bar
```
But this DOESN'T work:
```ruby
o = Object.new
o.tap { def _1.bar(baz) = 'foo' }
p o.bar('baz')
```
So, when we define a method with parameters on an instance given as numbered parameters, it doesn't work. If we change one condition (definition way, parameter existence, and so on), it works.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/