From: "Eregon (Benoit Daloze)" Date: 2022-03-10T17:46:06+00:00 Subject: [ruby-core:107837] [Ruby master Feature#18621] Fiber.yield loses the fact it was kwargs from Fiber#resume Issue #18621 has been updated by Eregon (Benoit Daloze). Backport deleted (2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: REQUIRED, 3.1: REQUIRED) ruby -v deleted (ruby 3.2.0dev (2022-03-03T08:56:31Z master c1790f8c11) [x86_64-linux]) Status changed from Open to Rejected Tracker changed from Bug to Feature > So in order for it to work, the final line would need to be: foo(*[args]) Right, due to `make_passing_arg` indeed. > Be aware that if you go this direction, even if we remove the ruby2_keywords methods, the support for automatically treating hashes as keywords can never be removed, it must remain part of Ruby forever. This is a very good point, I think this is not worth fixing in light of that. I noticed this while implementing Ruby 3 kwargs in TruffleRuby, that basically the knowledge of "were kewargs passed" is lost in this case for `Fiber#resume` + `Fiber.yield`. But it's also kind of natural since `Fiber.yield` already "packs" the arguments as a single Object or an Array, and there is no built-in object to represent all arguments currently: `*args, **kwargs` (and maybe also `&block`). I'll reject this as I think it's not really needed in practice (one could pass a lambda doing the call with kwargs), and relying on the `ruby2_keywords` flag for this seems hacky. ---------------------------------------- Feature #18621: Fiber.yield loses the fact it was kwargs from Fiber#resume https://bugs.ruby-lang.org/issues/18621#change-96767 * Author: Eregon (Benoit Daloze) * Status: Rejected * Priority: Normal ---------------------------------------- ```ruby f = Fiber.new do args = Fiber.yield args end f.resume args = f.resume(a: 1) Hash.ruby2_keywords_hash?(args) # => false, but should be true, isn't it? ``` This also means if there is `foo(*args)` later and `foo` would require kwargs it would fail: ```ruby def foo(a: 1) = a f = Fiber.new do args = Fiber.yield args end f.resume args = f.resume(a: 1) foo(*args) # => # -:1:in `foo': wrong number of arguments (given 1, expected 0) (ArgumentError) # from -:9:in `
' ``` cc @jeremyevans0 @mame -- https://bugs.ruby-lang.org/ Unsubscribe: