From: merch-redmine@... Date: 2019-07-29T19:03:35+00:00 Subject: [ruby-dev:50823] [Ruby master Bug#14240] warn four special variables: $; $, $/ $\ Issue #14240 has been updated by jeremyevans0 (Jeremy Evans). File warn-5-gvars-v2.patch added nobu (Nobuyoshi Nakada) wrote: > It does not match to test `rb_warn` with `assert_warning`. > Should be `rb_warn`+`assert_warn` or `rb_warning`+`assert_warning`. Thanks. I switched to `assert_warn`, as I think deprecation warnings should be a regular warning, not a verbose warning. Verbose warnings are best used for warnings like unused variables. I only think verbose deprecation warnings should be used if there is a plan to follow it up with a non-verbose deprecation warning before removing it. > And non-default `$;` and `$,` are warned now. > Do you think these **names** should be warned too? I don't feel strongly about it. The `$;` and `$,` are currently run-time warnings based on the specific values passed when setting the values. akr's previous comment indicated that the warnings of the five variables should be at compile time. One problem with the implementation in my previous patch is that it warns at the wrong location. Switching from `rb_warn` to `rb_compile_warn` fixes that issue. Attached is an updated patch, as well as a few fixes where the global variables are currently used. Another file where they are also currently used is in: ``` /path/ruby/lib/rubygems/stub_specification.rb:114: warning: global variable $. is deprecated /path/ruby/lib/rubygems/stub_specification.rb:134: warning: global variable $. is deprecated ``` But a fix there should be filed upstream. There are probably additional cases where these global variables are used internally. At the very least all tests that use them probably need modification to hide the warnings. ---------------------------------------- Bug #14240: warn four special variables: $; $, $/ $\ https://bugs.ruby-lang.org/issues/14240#change-80202 * Author: akr (Akira Tanaka) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- I think the four special variables for separators should be deprecated. ``` $/ input record separator (default argument for "gets") $\ output record separator ("print" prints it at last) $, default separator for Array#join and print $; default separator for String#split ``` I feel many program doesn't work if they are set to non-default value. Since they are global, not thread local, we can not change these variables safely in a multi threaded program. So, I think we should warn them (and delete them in future). ---Files-------------------------------- warn-5-gvars.patch (2.31 KB) warn-5-gvars-v2.patch (5.44 KB) -- https://bugs.ruby-lang.org/