[ruby-core:113352] [Ruby master Bug#19619] Endless method definition with parameters for an instance given as numbered parameters doesn't work

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/

Issue #19619 has been updated by okuramasafumi (Masafumi OKURA). The result of the last code: ``` undefined method `bar' for #<Object:0x0000000108e20438> (NoMethodError) ``` ---------------------------------------- Bug #19619: Endless method definition with parameters for an instance given as numbered parameters doesn't work https://bugs.ruby-lang.org/issues/19619#change-102913 * 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/

Issue #19619 has been updated by nobu (Nobuyoshi Nakada). Subject changed from Endless method definition with parameters for an instance given as numbered parameters doesn't work to Numbered parameters don't work with method definition with parameters Since this doesn't work too, endless and/or singleton method definition doesn't seem to matter. ```ruby 1.times {p _1; def bar; end} #=> 0 1.times {p _1; def bar x; end} #=> nil ``` ---------------------------------------- Bug #19619: Numbered parameters don't work with method definition with parameters https://bugs.ruby-lang.org/issues/19619#change-102924 * 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/

Issue #19619 has been updated by duerst (Martin Dürst). @nobu In the above commit, I think `node_new_temporary` would be clearer than `node_new_temporal`. ---------------------------------------- Bug #19619: Numbered parameters don't work with method definition with parameters https://bugs.ruby-lang.org/issues/19619#change-102970 * Author: okuramasafumi (Masafumi OKURA) * Status: Closed * 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/

Issue #19619 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED to 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONE ruby_3_2 commit:483ad38c6968feb1990f36d48d14fd55988d2150 merged revision(s) commit:b15e88e0fcccb03b9cc5e4c1478ec9b10e26c961. ---------------------------------------- Bug #19619: Numbered parameters don't work with method definition with parameters https://bugs.ruby-lang.org/issues/19619#change-109180 * Author: okuramasafumi (Masafumi OKURA) * Status: Closed * ruby -v: 3.2.2 * Backport: 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONE ---------------------------------------- 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/
participants (4)
-
duerst
-
nagachika (Tomoyuki Chikanaga)
-
nobu (Nobuyoshi Nakada)
-
okuramasafumi (Masafumi OKURA)