From 26c024e95999e545fbef85a25165234af77ea605 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 24 Dec 2012 21:14:02 +0100 Subject: silences "possibly useless use of :: in void context" warnings The AS utility silence_warnings does not really silence this one, because it is issued at parse-time. It seemed to in some places because the constant was the only expression in the block and therefore it was its return value, that could potentially be used by silence_warnings are return value of the yield call. To bypass the warning we assign to a variable. The chosen variable is "_" because it is special-cased in parse.c not to issue an "assigned but unused variable" warning in turn. --- activesupport/test/dependencies_test.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'activesupport/test') diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 51a7e4b2fe..9d913c27b0 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -923,10 +923,8 @@ class DependenciesTest < ActiveSupport::TestCase def test_remove_constant_does_not_autoload_already_removed_parents_as_a_side_effect with_autoloading_fixtures do - silence_warnings do - ::A - ::A::B - end + _ = ::A # assignment to silence parse-time warning "possibly useless use of :: in void context" + _ = ::A::B # assignment to silence parse-time warning "possibly useless use of :: in void context" ActiveSupport::Dependencies.remove_constant('A') ActiveSupport::Dependencies.remove_constant('A::B') assert !defined?(A) @@ -936,9 +934,7 @@ class DependenciesTest < ActiveSupport::TestCase def test_load_once_constants_should_not_be_unloaded with_autoloading_fixtures do ActiveSupport::Dependencies.autoload_once_paths = ActiveSupport::Dependencies.autoload_paths - silence_warnings do - ::A - end + _ = ::A # assignment to silence parse-time warning "possibly useless use of :: in void context" assert defined?(A) ActiveSupport::Dependencies.clear assert defined?(A) -- cgit v1.2.3