Project

General

Profile

Feature #16345

Updated by sawa (Tsuyoshi Sawada) about 5 years ago

We propose that Ruby doesn't emit deprecation warnings by default. 

 Deprecation warnings are only useful during when development for updating Ruby version. 
 They are not useful during when development with for current Ruby. 
 It is They are especially frustrating frustrated when deprecated warnings are generated in gems. 
 Also, deprecation warnings are totally useless in for production environment. 

 So, we want to emit deprecation warnings only in for useful situations. 

 We propose a command line argument `-W:deprecated` (or `--warning=deprecated`) 
 and the following methods to enable/disable deprecation warnings. 

 ```ruby 
 Warning.disable(:deprecated) 
 Warning.enable(:deprecated) 
 Warning.enabled?(:deprecated) 
 ``` 

 Currently we don't propose a method to generate a deprecation warning 
 because currently current our main intent is to disable disabling deprecation warnings for  
 keyword arguments, arguments and the warnings are generated in C level. 

 Background: 

 We talked discussed about keyword arguments during at a developer meeting (2019-11-12). 
 https://bugs.ruby-lang.org/issues/16333 
 We expect many deprecation warnings to will be generated in Ruby 2.7. 
 They are not useful except for development for Ruby transition, transition and 
 they may block transition to Ruby 2.7. 

 So, we have consensus to disable deprecation warnings by default. 
 Our design is intentionally minimum because we need this feature for Ruby 2.7. 

 We chose chosen `Warning.disable(:deprecated)` instead of 
 re-defining `Warning.warn` in order to avoid because avoiding string object generation. 

 Of course, we expect extension to extend this feature: 
 Ruby-level deprecation warning generation, 
 warnings other than deprecation,  
 file-based restriction of warning generation, etc. 
 But this issue doesn't contain them. 

Back