Project

General

Profile

Actions

Bug #18673

closed

Anonymous block forwarding fails when combined with keyword arguments

Added by brasic (Carl Brasic) almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:108148]

Description

Hello!

I tried to use the anonymous block forwarding feature introduced in https://bugs.ruby-lang.org/issues/11256 and released with ruby 3.1.

Unfortunately it appears to unexpectedly fail during parsing when used in a method that also accepts keyword arguments. I don't see this limitation documented so I presume it is a bug. I've attached a simple reproduction script.

/cc @jeremyevans0 (Jeremy Evans) as author.

$ ruby -v
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux]
$ ruby anon_repro.rb
anon_repro.rb:14: no anonymous block parameter

Carl


Files

anon_repro.rb (223 Bytes) anon_repro.rb brasic (Carl Brasic), 03/31/2022 10:14 PM

Updated by jeremyevans0 (Jeremy Evans) almost 2 years ago

This does seem to be a bug. It affects method that accept explicit keyword parameters (keyword splats are not affected, nor are methods that explicitly accept no keywords via **nil). I'll try to take a look in the coming week, hopefully it's a simple fix in parse.y. @mame (Yusuke Endoh) @nobu (Nobuyoshi Nakada), any ideas?

Updated by jeremyevans0 (Jeremy Evans) almost 2 years ago

  • Backport changed from 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: REQUIRED

I submitted a pull request to fix this issue: https://github.com/ruby/ruby/pull/5761

Actions #3

Updated by jeremyevans (Jeremy Evans) almost 2 years ago

  • Status changed from Open to Closed

Applied in changeset git|3bb70a6924ddd83f90b508b5bbc4d5629b8a41c6.


Fix using anonymous block in method accepting explicit keywords

Record block ID before vtable_pop, so the incorrect one doesn't
override it.

Fixes [Bug #18673]

Updated by nagachika (Tomoyuki Chikanaga) almost 2 years ago

  • Backport changed from 2.7: DONTNEED, 3.0: DONTNEED, 3.1: REQUIRED to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONE

ruby_3_1 750d4dc3aff7c2fef25fe99f1b98327f68734c9a merged revision(s) 3bb70a6924ddd83f90b508b5bbc4d5629b8a41c6.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0