Subject: | "Useless use of a constant in void context" in 5.6 from DEBUG |
The DEBUG change in 1.25 throws warnings in ActiveState's 5.6.1 (I have
not tried a stock 5.6 as I don't have one available). Sorry, I should
have checked it out. Simply loading the module produces...
Useless use of a constant in void context at lib/Class/Autouse.pm line 77.
Useless use of a constant in void context at lib/Class/Autouse.pm line 96.
Useless use of a constant in void context at lib/Class/Autouse.pm line 123.
Useless use of a constant in void context at lib/Class/Autouse.pm line 182.
Useless use of a constant in void context at lib/Class/Autouse.pm line 211.
Useless use of a constant in void context at lib/Class/Autouse.pm line 221.
Useless use of a constant in void context at lib/Class/Autouse.pm line 230.
Useless use of a constant in void context at lib/Class/Autouse.pm line 244.
Useless use of a constant in void context at lib/Class/Autouse.pm line 266.
Useless use of a constant in void context at lib/Class/Autouse.pm line 371.
Useless use of a constant in void context at lib/Class/Autouse.pm line 399.
Useless use of a constant in void context at lib/Class/Autouse.pm line 414.
Useless use of a constant in void context at lib/Class/Autouse.pm line 476.
Useless use of a constant in void context at lib/Class/Autouse.pm line 495.
Useless use of a constant in void context at lib/Class/Autouse.pm line 520.
Useless use of a constant in void context at lib/Class/Autouse.pm line 539.
Useless use of a constant in void context at lib/Class/Autouse.pm line 17.
Each of those corresponds to an "if DEBUG". Its some 5.6 bug (possibly
confined to ActiveState's version) where if a constant is set to undef
it will throw the above warning.
$ perl -wle 'use constant FOO => undef; print "This" if FOO'
Useless use of a constant in void context at -e line 1.
Patch attached to make sure $DEBUG is always defined.
--- Class-Autouse-1.25/lib/Class/Autouse.pm Fri Apr 7 05:27:53 2006
+++ Class-Autouse-1.25.fixed/lib/Class/Autouse.pm Tue Apr 11
16:25:27 2006@@ -13,6 +13,9 @@
# Handle debugging switch via a constant to allow debugging
# to be optimised out at compile time if not needed.
use vars qw{$DEBUG};
+# Avoid a 5.6 bug where a constant set to undef throws a "useless use of
+# constant in void context" warning.
+BEGIN { $DEBUG ||= 0 }
use constant DEBUG => $DEBUG;
print "Class::Autouse::autoload -> Debugging Activated.\n" if DEBUG;