Project

General

Profile

Actions

Bug #16856

closed

Structs accepting keyword arguments issue a warning with Ruby 2.7

Added by iGEL (Johannes Barre) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
[ruby-core:98327]

Description

This code is issuing a warning with Ruby 2.7, but should not:

class NotFine < Struct.new(:x)
  def initialize(x, arg:)
  end
end

class Fine
  def initialize(x, arg:)
  end
end

NotFine.new(1, arg: 1) # This is causing the warning
Fine.new(1, arg: 1)    # This is not
$ ruby test.rb
test.rb:11: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
test.rb:2: warning: The called method `initialize' is defined here
Actions

Also available in: Atom PDF

Like0
Like0