SU 2019.2 - warning: shadowing outer local variable, $VERBOSE

After updating to 2019.2, I did receive a few warning: shadowing outer local variable messages from $VERBOSE = true.

Most dev’s should leave that false or nil for plugin distros.

JFYI, I’ve got a 2nd install of SU 2019 running with Ruby 2.7 (Windows), and the warnings did not appear. Warnings and all the code paths are kind of messy to test for…

I do not see any warnings on MS Windows within SU2019.2 running Ruby 2.5.5-p157.

I tested entering all 3 assignments at the console …

$VERBOSE = true
#=> true
$VERBOSE = false
#=> false
$VERBOSE = nil

I see No warnings.

FYI … (a tip) …

What I do, when I do not want warnings to clutter console output, is have a “silently” method that can run blocks without spitting out warnings.

def silently
  return nil unless block_given?
  prev, $VERBOSE = $VERBOSE, nil
    result = yield
    $VERBOSE = prev

And to use …

silently do
  # code that usually produces warnings like constant already defined, etc.


Sorry, the warning I mentioned (shadowing outer local variable), appeared from code I was loading after updating to 2019.2 / Ruby 2.5.5. It did not generate a warning with Ruby 2.5.1 or Ruby 2.7.0.

I as sort of alluded to above, warnings have become more common with newer Ruby versions to warn about potential issues. But, since they’re hard to test, sometimes false warnings are shown.

Hence, warnings should be reviewed, but may not require code changes. Remember that warnings today may become compile failures in a future Ruby version…

1 Like