Project

General

Profile

Actions

Bug #20570

closed

Nokey behavior changed since 3.3.

Added by ksss (Yuki Kurihara) 5 months ago. Updated 5 months ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 3.3.2 (2024-05-30 revision e5a195edf6) [arm64-darwin22]
[ruby-core:118269]

Description

I am using code that transfers the following method call, but found that the behavior has changed since CRuby 3.3.

receiver_value = Set.new
method_name = :merge
args = [1]
kwargs = {}
block = nil
receiver_value.__send__(method_name, *args, **kwargs, &block)
# => no keywords accepted (ArgumentError)

Upon investigation, I found that the behavior of calling a method using **nil has changed starting from version 3.3.

$ docker run -it --rm rubylang/all-ruby env ALL_RUBY_SINCE=ruby-2.6 ./all-ruby -e 'def foo(*, **nil); end; p foo(*[], **{})'
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
ruby-2.6.0          -e:1: syntax error, unexpected nil, expecting ')'
                    def foo(*, **nil); end; p foo(*[], **{})
                                 ^~~
                exit 1
...
ruby-2.6.10         -e:1: syntax error, unexpected nil, expecting ')'
                    def foo(*, **nil); end; p foo(*[], **{})
                                 ^~~
                exit 1
ruby-2.7.0-preview1 -e:1: syntax error, unexpected `nil', expecting ')'
                    def foo(*, **nil); end; p foo(*[], **{})
                                 ^~~
                exit 1
ruby-2.7.0-preview2 nil
...
ruby-3.2.4          nil
ruby-3.3.0-preview1 -e:1:in `<main>': no keywords accepted (ArgumentError)

                    def foo(*, **nil); end; p foo(*[], **{})
                                                  ^^^^^^^^^
                exit 1
...
ruby-3.3.2          -e:1:in `<main>': no keywords accepted (ArgumentError)

                    def foo(*, **nil); end; p foo(*[], **{})
                                                  ^^^^^^^^^
                exit 1
ruby-3.4.0-preview1 -e:1:in '<main>': no keywords accepted (ArgumentError)

                    def foo(*, **nil); end; p foo(*[], **{})
                                                  ^^^^^^^^^
                exit 1

Is this change intentional?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like1Like0Like0Like0Like0Like0Like0