ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:101427] [Ruby master Bug#17388] Doesn't Warning.warn support `category: :experimental` in Ruby 3.0.0?
@ 2020-12-12 11:08 me
  2020-12-14 19:07 ` [ruby-core:101450] " zverok.offline
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: me @ 2020-12-12 11:08 UTC (permalink / raw
  To: ruby-core

Issue #17388 has been reported by jnchito (Junichi Ito).

----------------------------------------
Bug #17388: Doesn't  Warning.warn support `category: :experimental` in Ruby 3.0.0?
https://bugs.ruby-lang.org/issues/17388

* 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
----------------------------------------
I wrote the following script:

```ruby
module Warning
  def self.warn(message, category: nil)
    puts "category=#{category}"
    super
  end
end
lambda(&:foo).lambda?
Ractor.new{}
```

Then, run it:

```
$ ruby -w ~/Desktop/test.rb
category=deprecated
/Users/jnito/Desktop/test.rb:7: warning: lambda without a literal block is deprecated; use the proc without lambda instead
category=
<internal:ractor>:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
```

I got `category=deprecated` as I expected, but got `nil` instead of `:experimental`. I feel it should be `:experimental`.

This issue is related to https://bugs.ruby-lang.org/issues/17122




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:101450] [Ruby master Bug#17388] Doesn't Warning.warn support `category: :experimental` in Ruby 3.0.0?
  2020-12-12 11:08 [ruby-core:101427] [Ruby master Bug#17388] Doesn't Warning.warn support `category: :experimental` in Ruby 3.0.0? me
@ 2020-12-14 19:07 ` zverok.offline
  2020-12-14 20:45 ` [ruby-core:101453] " merch-redmine
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: zverok.offline @ 2020-12-14 19:07 UTC (permalink / raw
  To: ruby-core

Issue #17388 has been updated by zverok (Victor Shepelev).


In addition:

```ruby
warn('foo', category: :deprecated) # works
warn('foo', category: :experimental)
# ArgumentError (invalid warning category used: experimental)
```

It all comes down to this commit: https://github.com/ruby/ruby/commit/346301e2329c46362a6089311d0a64b8734b35ec
Stating
> The only currently defined warning category is `:deprecated`, since that is what is already used.  More categories can be added in later commits.

TBH, I am not sure why this method needs to use a [separate hash](https://github.com/ruby/ruby/commit/346301e2329c46362a6089311d0a64b8734b35ec#diff-f2e6c18de8171e389aeff0b8d25b2755253108a59a13baf7167c2ffa0af36a58R2797), instead of supporting all the categories `Warning[]` supports?..

@jeremyevans0, can you please explain?

----------------------------------------
Bug #17388: Doesn't  Warning.warn support `category: :experimental` in Ruby 3.0.0?
https://bugs.ruby-lang.org/issues/17388#change-89220

* 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
----------------------------------------
I wrote the following script:

```ruby
module Warning
  def self.warn(message, category: nil)
    puts "category=#{category}"
    super
  end
end
lambda(&:foo).lambda?
Ractor.new{}
```

Then, run it:

```
$ ruby -w ~/Desktop/test.rb
category=deprecated
/Users/jnito/Desktop/test.rb:7: warning: lambda without a literal block is deprecated; use the proc without lambda instead
category=
<internal:ractor>:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
```

I got `category=deprecated` as I expected, but got `nil` instead of `:experimental`. I feel it should be `:experimental`.

This issue is related to https://bugs.ruby-lang.org/issues/17122




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:101453] [Ruby master Bug#17388] Doesn't Warning.warn support `category: :experimental` in Ruby 3.0.0?
  2020-12-12 11:08 [ruby-core:101427] [Ruby master Bug#17388] Doesn't Warning.warn support `category: :experimental` in Ruby 3.0.0? me
  2020-12-14 19:07 ` [ruby-core:101450] " zverok.offline
@ 2020-12-14 20:45 ` merch-redmine
  2020-12-15  0:58 ` [ruby-core:101461] " me
  2020-12-15  7:32 ` [ruby-core:101463] " nobu
  3 siblings, 0 replies; 5+ messages in thread
From: merch-redmine @ 2020-12-14 20:45 UTC (permalink / raw
  To: ruby-core

Issue #17388 has been updated by jeremyevans0 (Jeremy Evans).

File experimental.diff added

zverok (Victor Shepelev) wrote in #note-1:
> In addition:
> 
> ```ruby
> warn('foo', category: :deprecated) # works
> warn('foo', category: :experimental)
> # ArgumentError (invalid warning category used: experimental)
> ```
> 
> It all comes down to this commit: https://github.com/ruby/ruby/commit/346301e2329c46362a6089311d0a64b8734b35ec
> Stating
> > The only currently defined warning category is `:deprecated`, since that is what is already used.  More categories can be added in later commits.
> 
> TBH, I am not sure why this method needs to use a [separate hash](https://github.com/ruby/ruby/commit/346301e2329c46362a6089311d0a64b8734b35ec#diff-f2e6c18de8171e389aeff0b8d25b2755253108a59a13baf7167c2ffa0af36a58R2797), instead of supporting all the categories `Warning[]` supports?..
> 
> @jeremyevans0, can you please explain?

`Warning.[]` does not use a hash, it uses an if/else construction.  So there wasn't an existing hash I could use, I had to create a new hash.

I'm not opposed to supporting an :experimental category.  It's not used internally though.  There are only three internal callers that respect the `Warning[:experimental] = false`, and none of them call the warning method in that case. When they do call the warning method, they don't use a category.  If we are going to add support for an :experimental category, we should probably change the cases that respect `Warning[:experimental] = false` to use the :experimental category when emitting the warning.  That's more complex than you probably expect, see the attached patch (no tests yet, and not sure about the ripper support).

Considering the current state of category support in Warning.warn, I would be in favor of removing category support completely in Ruby 3.0 and not adding similar support back until we have a better idea.  @nobu mentioned that warnings should probably support multiple tags instead of a single category, and that sounds better to me. I feel that a :category keyword that only supports 1 or 2 categories is of so little practical use that it isn't worth supporting.

----------------------------------------
Bug #17388: Doesn't  Warning.warn support `category: :experimental` in Ruby 3.0.0?
https://bugs.ruby-lang.org/issues/17388#change-89224

* 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
----------------------------------------
I wrote the following script:

```ruby
module Warning
  def self.warn(message, category: nil)
    puts "category=#{category}"
    super
  end
end
lambda(&:foo).lambda?
Ractor.new{}
```

Then, run it:

```
$ ruby -w ~/Desktop/test.rb
category=deprecated
/Users/jnito/Desktop/test.rb:7: warning: lambda without a literal block is deprecated; use the proc without lambda instead
category=
<internal:ractor>:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
```

I got `category=deprecated` as I expected, but got `nil` instead of `:experimental`. I feel it should be `:experimental`.

This issue is related to https://bugs.ruby-lang.org/issues/17122


---Files--------------------------------
experimental.diff (5.2 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:101461] [Ruby master Bug#17388] Doesn't Warning.warn support `category: :experimental` in Ruby 3.0.0?
  2020-12-12 11:08 [ruby-core:101427] [Ruby master Bug#17388] Doesn't Warning.warn support `category: :experimental` in Ruby 3.0.0? me
  2020-12-14 19:07 ` [ruby-core:101450] " zverok.offline
  2020-12-14 20:45 ` [ruby-core:101453] " merch-redmine
@ 2020-12-15  0:58 ` me
  2020-12-15  7:32 ` [ruby-core:101463] " nobu
  3 siblings, 0 replies; 5+ messages in thread
From: me @ 2020-12-15  0:58 UTC (permalink / raw
  To: ruby-core

Issue #17388 has been updated by jnchito (Junichi Ito).


jeremyevans0 (Jeremy Evans) wrote in #note-2:
> If we are going to add support for an :experimental category, we should probably change the cases that respect `Warning[:experimental] = false` to use the :experimental category when emitting the warning.  That's more complex than you probably expect, see the attached patch (no tests yet, and not sure about the ripper support).

Thank you for your comment. IMO, it would be enough if the current implementation is documented (like "currently supported category is `:deprecated` only.") 

----------------------------------------
Bug #17388: Doesn't  Warning.warn support `category: :experimental` in Ruby 3.0.0?
https://bugs.ruby-lang.org/issues/17388#change-89230

* 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
----------------------------------------
I wrote the following script:

```ruby
module Warning
  def self.warn(message, category: nil)
    puts "category=#{category}"
    super
  end
end
lambda(&:foo).lambda?
Ractor.new{}
```

Then, run it:

```
$ ruby -w ~/Desktop/test.rb
category=deprecated
/Users/jnito/Desktop/test.rb:7: warning: lambda without a literal block is deprecated; use the proc without lambda instead
category=
<internal:ractor>:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
```

I got `category=deprecated` as I expected, but got `nil` instead of `:experimental`. I feel it should be `:experimental`.

This issue is related to https://bugs.ruby-lang.org/issues/17122


---Files--------------------------------
experimental.diff (5.2 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:101463] [Ruby master Bug#17388] Doesn't Warning.warn support `category: :experimental` in Ruby 3.0.0?
  2020-12-12 11:08 [ruby-core:101427] [Ruby master Bug#17388] Doesn't Warning.warn support `category: :experimental` in Ruby 3.0.0? me
                   ` (2 preceding siblings ...)
  2020-12-15  0:58 ` [ruby-core:101461] " me
@ 2020-12-15  7:32 ` nobu
  3 siblings, 0 replies; 5+ messages in thread
From: nobu @ 2020-12-15  7:32 UTC (permalink / raw
  To: ruby-core

Issue #17388 has been updated by nobu (Nobuyoshi Nakada).


BTW, `rb_category_warn` and `rb_category_warning` take the category as a string instead of `rb_warning_category_t`?

I was going to move it under "include/" when exposing functions that use it...

----------------------------------------
Bug #17388: Doesn't  Warning.warn support `category: :experimental` in Ruby 3.0.0?
https://bugs.ruby-lang.org/issues/17388#change-89233

* 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
----------------------------------------
I wrote the following script:

```ruby
module Warning
  def self.warn(message, category: nil)
    puts "category=#{category}"
    super
  end
end
lambda(&:foo).lambda?
Ractor.new{}
```

Then, run it:

```
$ ruby -w ~/Desktop/test.rb
category=deprecated
/Users/jnito/Desktop/test.rb:7: warning: lambda without a literal block is deprecated; use the proc without lambda instead
category=
<internal:ractor>:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
```

I got `category=deprecated` as I expected, but got `nil` instead of `:experimental`. I feel it should be `:experimental`.

This issue is related to https://bugs.ruby-lang.org/issues/17122


---Files--------------------------------
experimental.diff (5.2 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-15  7:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-12 11:08 [ruby-core:101427] [Ruby master Bug#17388] Doesn't Warning.warn support `category: :experimental` in Ruby 3.0.0? me
2020-12-14 19:07 ` [ruby-core:101450] " zverok.offline
2020-12-14 20:45 ` [ruby-core:101453] " merch-redmine
2020-12-15  0:58 ` [ruby-core:101461] " me
2020-12-15  7:32 ` [ruby-core:101463] " nobu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).