New 2.7/3.0 keyword argument pain point

I think we should be more gradual with keyword argument migration, and as a first important step keep *args-delegation working for 2.7, 3.0, etc. And only warn later about it with precise warnings telling what to do (e.g., use *args,**kwargs-delegation which needs Ruby 3.0+), when it’s reasonable for most libraries to drop 2.7 support (~ Ruby 3.4). That way we don’t need ruby2_keywords, and libraries don’t need to change delegation code twice.

Now, delegation code is probably not very frequent, but the current warnings are particularly unhelpful about it, and the only workaround for 2.7.0 & 2.7.1 is ruby2_keywords which I feel is a hack to write in library code.

I think other warnings related to keyword arguments are much easier to address by having precise warnings for them, and often the fix is obvious.
I’m curious to hear other opinions.

@Thibaut_Barrere shows what intuitively should work, either *args or *args, **kwargs delegation, But both don’t work in 2.7 (only ruby2_keywords works in 2.7.0 & 2.7.1), and I think that should be fixed.

Keeping *args delegation working is simple, see Feature #16463: Fixing *args-delegation in Ruby 2.7: ruby2_keywords semantics by default in 2.7.1 - Ruby master - Ruby Issue Tracking System. It passes Rails’s CI and is even more compatible with Ruby 2.6.

6 Likes