Bug #16438
closedCheck warning messages for Ruby 2.7
Description
Please check Ruby 2.7 new introduced warning messages.
- deprecation warning
def foo(**kw)
end
foo({}) #=> test.rb:4: warning: The last argument is used as the keyword parameter
# test.rb:1: warning: for `foo' defined here; maybe ** should be added to the call?
# deafult: on
_1 = 2
#=>
# t.rb:1: warning: `_1' is used as numbered parameter
# default: on
def _1; end
#=> test.rb:1: warning: `_1' is used as numbered parameter
# deafult: on
# added at Today!!
def foo
proc.call #=> 1
end
foo{p 1}
#=>
# t.rb:2: warning: Capturing the given block using Kernel#proc is deprecated; use `&block` instead
# 1
# default: on
$; = //
#=> t.rb:1: warning: non-nil $; will be deprecated
$, = ''
#=> t.rb:2: warning: non-nil $, will be deprecated
# default: on
def foo
class << Object.new
yield
end
end
foo { p :ok } #=> warning: `yield' in class syntax will not be supported from Ruby 3.0.
# default: on
require 'open-uri'
open('http://atdot.net')
#=> test.rb:2: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open
# default: on
- experimental feature
$ ./miniruby -e 'case 1; in 1; end'
-e:1: warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!
# default: on
Updated by osyo (manga osyo) almost 5 years ago
def _1; end
#=> test.rb:1: warning: `_1' is used as numbered parameter
Warn by parameter name instead of method name.
Became warning.
# warning: `_1' is used as numbered parameter
def _1; end
# warning: `_1' is used as numbered parameter
def hoge(_1); end
Updated by ko1 (Koichi Sasada) almost 5 years ago
$SAFE = 1
#=> t.rb:1: warning: $SAFE will become a normal global variable in Ruby 3.0
no warning¶
pls check current master.
Updated by osyo (manga osyo) almost 5 years ago
pls check current master.
Sorry, became warning.
Updated by nobu (Nobuyoshi Nakada) almost 5 years ago
- Status changed from Open to Closed
Applied in changeset git|a8bddb3a189545a2bef8ee7cffdb328d8de7974c.
Refined the warning message for numbered-parameter like variables
[Bug #16438]
Updated by ko1 (Koichi Sasada) almost 5 years ago
At developer's meeting, the followings are proposed. They will be merged into Ruby 2.7 RC2.
def foo(**kw)
end
foo({})
# current:
#=> test.rb:4: warning: The last argument is used as the keyword parameter
# test.rb:1: warning: for `foo' defined here; maybe ** should be added to the call?
# modified (conclusion):
#=> test.rb:4: warning: The last argument is used as keyword parameters; maybe ** should be added to the call
# test.rb:1: warning: The called method `foo' is defined here
# t.rb:1: warning: `_1' is used as numbered parameter
->
# t.rb:1: warning: `_1' is reserved for numbered parameter; consider another name
#=> t.rb:1: warning: non-nil $; will be deprecated
=>
#=> t.rb:1: warning: `$;' is deprecated
Updated by puchuu (Andrew Aladjev) almost 5 years ago
Hello. I can't understand why setting OFS to not nil value was deprecated. I want to simulate print method behaviour and I am using $OUTPUT_FIELD_SEPARATOR
between objects. Than I want to test this method, so I am settings OFS to not nil value in tests. Ruby 2.7.0 throws deprecated warning.
Updated by puchuu (Andrew Aladjev) almost 5 years ago
I see the only one way to fix this deprecation. Change write(*objects)
signature to print(*objects, field_separator: $OUTPUT_FIELD_SEPARATOR, record_separator: $OUTPUT_RECORD_SEPARATOR)
and test print by passing separators directly. Will ruby change print signature in the same way?