[#101179] Spectre Mitigations — Amel <amel.smajic@...>
Hi there!
5 messages
2020/12/01
[#101694] Ruby 3.0.0 Released — "NARUSE, Yui" <naruse@...>
V2UgYXJlIHBsZWFzZWQgdG8gYW5ub3VuY2UgdGhlIHJlbGVhc2Ugb2YgUnVieSAzLjAuMC4gRnJv
4 messages
2020/12/25
[ruby-core:101431] [Ruby master Bug#17387] About Warning.warn compatibility in Ruby 3.0.0
From:
me@...
Date:
2020-12-12 21:51:32 UTC
List:
ruby-core #101431
Issue #17387 has been updated by jnchito (Junichi Ito).
Eregon (Benoit Daloze) wrote in #note-2:
> The English documentation seems fine:
> https://docs.ruby-lang.org/en/master/Warning.html#method-i-warn
>
> So I guess the Japanese docs should be updated.
Thank you for information. I noticed the first parameter can be string and array according to the method signature.
```ruby
module Warning
def self.warn(message)
p message #=> "my warning\n"
super
end
end
warn "my warning"
```
```ruby
module Warning
def self.warn(*message)
p message #=> ["my warning\n"]
super
end
end
warn "my warning"
```
The both can run in Ruby 2.7, but the latter won't run in Ruby 3.0.0 with the message below:
```
$ ruby ~/Desktop/test.rb
["my warning\n", {:category=>nil}]
/Users/jnito/Desktop/test.rb:4:in `warn': wrong number of arguments (given 2, expected 1) (ArgumentError)
from /Users/jnito/Desktop/test.rb:4:in `warn'
from <internal:warning>:43:in `warn'
from /Users/jnito/Desktop/test.rb:7:in `<main>'
```
Therefore, the compatibility is broken (the parameter `message` should be `["my warning\n"]`). Is it a bug or not?
----------------------------------------
Bug #17387: About Warning.warn compatibility in Ruby 3.0.0
https://bugs.ruby-lang.org/issues/17387#change-89198
* Author: jnchito (Junichi Ito)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0preview2 (2020-12-08 master d7a16670c3) [x86_64-darwin20]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
The sample code in https://docs.ruby-lang.org/ja/latest/method/Warning/s/warn.html does not work in Ruby 3.0.0. Is it intended behavior? I'm worrying about its compatibility.
``` ruby
warn "hoge"
module Warning
def self.warn(*message)
super(*message.map { |msg| msg.chomp + "!!!\n" })
end
end
warn "hoge"
```
```
$ ruby ~/Desktop/test.rb
hoge
/Users/jnito/Desktop/test.rb:5:in `block in warn': undefined method `chomp' for {:category=>nil}:Hash (NoMethodError)
from /Users/jnito/Desktop/test.rb:5:in `map'
from /Users/jnito/Desktop/test.rb:5:in `warn'
from <internal:warning>:43:in `warn'
from /Users/jnito/Desktop/test.rb:9:in `<main>'
```
This issue must be related to https://bugs.ruby-lang.org/issues/17122
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>