diff --git a/NEWS.md b/NEWS.md index 00e9667603..b1a5791c84 100644 --- a/NEWS.md +++ b/NEWS.md @@ -59,6 +59,33 @@ Note that each entry is kept to a minimum, see links for details. * Find pattern is no longer experimental. [[Feature #18585]] +* Methods taking a rest parameter (like `*args`) and wishing to delegate keyword + arguments through `foo(*args)` must now be marked with `ruby2_keywords` + (if not already the case). In other words, all methods wishing to delegate + keyword arguments through `*args` must now be marked with `ruby2_keywords`, + with no exception. This will make it easier to transition to other ways of + delegation once a library can require Ruby 3+. Previously, the `ruby2_keywords` + flag was kept if the receiving method took `*args`, but this was a bug and an + inconsistency. [[Bug #18625]] [[Bug #16466]] + + ```ruby + def target(**kw) + end + + # Accidentally worked without ruby2_keywords in Ruby 2.7-3.1, ruby2_keywords + # needed in 3.2+. Just like (*args, **kwargs) or (...) would be needed on + # both #foo and #bar when migrating away from ruby2_keywords. + ruby2_keywords def bar(*args) + target(*args) + end + + ruby2_keywords def foo(*args) + bar(*args) + end + + foo(k: 1) + ``` + ## Command line options ## Core classes updates @@ -203,6 +230,7 @@ The following deprecated APIs are removed. [Feature #15357]: https://bugs.ruby-lang.org/issues/15357 [Bug #15928]: https://bugs.ruby-lang.org/issues/15928 [Feature #16131]: https://bugs.ruby-lang.org/issues/16131 +[Bug #16466]: https://bugs.ruby-lang.org/issues/16466 [Feature #16806]: https://bugs.ruby-lang.org/issues/16806 [Bug #16889]: https://bugs.ruby-lang.org/issues/16889 [Bug #16908]: https://bugs.ruby-lang.org/issues/16908 @@ -217,4 +245,5 @@ The following deprecated APIs are removed. [Feature #18571]: https://bugs.ruby-lang.org/issues/18571 [Feature #18585]: https://bugs.ruby-lang.org/issues/18585 [Feature #18598]: https://bugs.ruby-lang.org/issues/18598 +[Bug #18625]: https://bugs.ruby-lang.org/issues/18625 [Bug #18633]: https://bugs.ruby-lang.org/issues/18633