From: "nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@...>
Date: 2024-03-14T08:58:50+00:00
Subject: [ruby-core:117145] [Ruby master Feature#20293] Add `Warning.categories` method that returns the warning category names

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


https://github.com/ruby/ruby/pull/10069

----------------------------------------
Feature #20293: Add `Warning.categories` method that returns the warning category names
https://bugs.ruby-lang.org/issues/20293#change-107226

* Author: nobu (Nobuyoshi Nakada)
* Status: Open
----------------------------------------
I propose a new method `Warning.categories`.
This would be useful (or necessary) for tests mainly.

Currently, `EnvUtil.capture_global_values` saves the original warning settings as followings:

```ruby
      @original_warning = defined?(Warning.[]) ? %i[deprecated experimental].to_h {|i| [i, Warning[i]]} : nil
```

But this is wrong now; `performance` is missing.
So we need:
```ruby
      @original_warning = if defined?(Warning.[]) # 2.7+
        %i[deprecated experimental performance].to_h do |i|
          [i, begin Warning[i]; rescue ArgumentError; end]
        end.compact
      end
```

That means this list is version dependent and we will need to maintain this list in future.
We need another surefire way.




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/