3 This patch adds lexical warnings to Perl. It should apply over
6 NOTE: This is a prototype. Do not assume that lexical warnings will
7 necessarily be anything like this implementation.
14 * patch now applies cleanly over 5.004_64
16 * added the -X switch (the inverse "lint" command)
20 * By popular demand, the warnings bitmask can now be of arbitrary
21 length. The code uses an SV* to store the bitmask.
23 * Rationalised the warning categories a bit. This area still needs
26 * Added -W switch (the "lint" command).
28 * Added an experimental feature to allow warnings to be excalated
32 The "use warning" pragma
33 ========================
35 The "use warning" pragma is intended to replace both the use of the
36 command line flag "-w" and its equivalent variable $^W with a pragma
37 that works like the existing "strict" pragma.
39 This means that the scope of the pragma is limited to the enclosing
40 block. It also means that that a pragma setting will not leak across
41 files (via use/require/do). This will allow authors to define the
42 degree of warning checks that will be applied to their module.
44 By default warnings are disabled.
46 All warnings are enabled in a block by either of these:
51 Similarly all warnings are disabled in a block by either of these:
56 A hierarchy of "categories" have been defined to allow groups of
57 warnings to be enabled/disabled in isolation. The current
60 all - +--- unsafe -------+--- taint
70 +--- io ---------+--- pipe
80 +--- syntax ----+--- ambiguous
108 This hierarchy is very tentative. Feedback is needed.
110 Just like the "strict" pragma any of these categories can be
113 use warning qw(void redefine) ;
114 no warning qw(io syntax untie) ;
119 If the -W flag is used on the command line, it will enable all warnings
120 throughout the program regardless of whether warnings were disabled
121 locally using "no warning" or $^W =0. This includes any file that gets
122 included during compilation via use/require.
124 The inverse "lint" flag, -X
125 ===========================
126 Does exactly the same as the -W flag, except it disables all warnings.
129 Backward Compatability
130 ======================
132 How Lexical Warnings interact with -w/$^W
134 1. The -w flag just sets the global $^W variable as in 5.004
135 This means that any legacy code that currently relies on
136 manipulating $^W to control warning behaviour will still work.
138 2. Apart from now being a boolean, the $^W variable operates in
139 exactly the same horrible uncontrolled global way as in 5.004,
142 3. If a piece of code is under the control of a lexical warning
143 pragma, the $^W variable will be ignored.
145 The combined effect of 2 & 3 is that it will will allow new code
146 which will use the lexical warning pragma to control old
147 $^W-type code (using a local $^W=0) if it really wants to, but
150 4. The only way to override a lexical warnings setting is with the
151 new -W or -X command line flags.
157 This feature is very experimental.
159 The presence of the word "FATAL" in the category list will escalate any
160 warnings from the category specified that are detected in the lexical
161 scope into fatal errors. In the code below, there are 3 places where a
162 deprecated warning will be detected, the middle one will produce a
171 use warning qw(FATAL deprecated) ;
181 test harness for -X (assuming it is a permanent fixture).
182 win32, os2 & vms all have warnings. These need to be included.
193 Hierarchy of Warnings
194 The current patch has a fairly arbitrary hierarchy.
195 Ideas for a useful hierarchy would be most welcome.
197 A command line option to turn off all warnings?
200 Current mandatory warnings.
201 May be useful to bring them under the control of this pragma.
204 Do we want/need a severity classification?
211 This is a thorhy issue. Say someone writes a script using Perl
212 5.004 and places this at the top:
216 Time passes and 5.005 comes out. It has added a few extra warnings.
217 The script prints warning messages.
219 A possibility is to allow the warnings that are checked to be
220 limited to those available in a given version of Perl. A possible
227 use warning 5.004 qw(void uninitialized) ;
229 Do we really need this amount of control?
236 The debugger saves and restores $^W at runtime. I haven't checked
237 whether the debugger will still work with the lexical warnings
241 I *think* I've got diagnostics to work with the lexiacal warnings
242 patch, but there were design decisions made in diagnostics to work
243 around the limitations of $^W. Now that those limitations are gone,
244 the module should be revisited.