Commit | Line | Data |
---|---|---|
767a6a26 | 1 | pp_hot.c |
599cee73 | 2 | |
2dd78f96 | 3 | print() on unopened filehandle abc [pp_print] |
599cee73 PM |
4 | $f = $a = "abc" ; print $f $a |
5 | ||
767a6a26 | 6 | Filehandle %s opened only for input [pp_print] |
599cee73 PM |
7 | print STDIN "abc" ; |
8 | ||
767a6a26 | 9 | Filehandle %s opened only for output [pp_print] |
977289e4 | 10 | $a = <STDOUT> ; |
599cee73 | 11 | |
9a7dcd9c | 12 | print() on closed filehandle %s [pp_print] |
599cee73 PM |
13 | close STDIN ; print STDIN "abc" ; |
14 | ||
767a6a26 | 15 | uninitialized [pp_rv2av] |
599cee73 PM |
16 | my $a = undef ; my @b = @$a |
17 | ||
767a6a26 | 18 | uninitialized [pp_rv2hv] |
599cee73 PM |
19 | my $a = undef ; my %b = %$a |
20 | ||
767a6a26 | 21 | Odd number of elements in hash list [pp_aassign] |
599cee73 PM |
22 | %X = (1,2,3) ; |
23 | ||
767a6a26 | 24 | Reference found where even-sized list expected [pp_aassign] |
599cee73 PM |
25 | $X = [ 1 ..3 ]; |
26 | ||
767a6a26 PM |
27 | Filehandle %s opened only for output [Perl_do_readline] |
28 | open (FH, ">./xcv") ; | |
29 | my $a = <FH> ; | |
30 | ||
31 | glob failed (can't start child: %s) [Perl_do_readline] <<TODO | |
32 | ||
9a7dcd9c | 33 | readline() on closed filehandle %s [Perl_do_readline] |
599cee73 PM |
34 | close STDIN ; $a = <STDIN>; |
35 | ||
790090df HS |
36 | readline() on closed filehandle %s [Perl_do_readline] |
37 | readline(NONESUCH); | |
38 | ||
767a6a26 PM |
39 | glob failed (child exited with status %d%s) [Perl_do_readline] <<TODO |
40 | ||
41 | Deep recursion on subroutine \"%s\" [Perl_sub_crush_depth] | |
6bc102ca | 42 | sub fred { fred() if $a++ < 200} fred() |
599cee73 | 43 | |
767a6a26 | 44 | Deep recursion on anonymous subroutine [Perl_sub_crush_depth] |
6bc102ca | 45 | $a = sub { &$a if $a++ < 200} &$a |
599cee73 | 46 | |
d804643f SC |
47 | Use of reference "%s" as array index [pp_aelem] |
48 | $x[\1] | |
49 | ||
599cee73 | 50 | __END__ |
767a6a26 | 51 | # pp_hot.c [pp_print] |
4438c4b7 | 52 | use warnings 'unopened' ; |
599cee73 | 53 | $f = $a = "abc" ; |
0453d815 | 54 | print $f $a; |
4438c4b7 | 55 | no warnings 'unopened' ; |
0453d815 | 56 | print $f $a; |
cf26e47f NC |
57 | use warnings; |
58 | no warnings 'unopened' ; | |
59 | print $f $a; | |
599cee73 | 60 | EXPECT |
2dd78f96 | 61 | print() on unopened filehandle abc at - line 4. |
599cee73 | 62 | ######## |
767a6a26 | 63 | # pp_hot.c [pp_print] |
1e00d6e9 FC |
64 | use warnings 'unopened' ; |
65 | $SIG{__WARN__} = sub { warn $_[0] =~ s/\0/\\0/rug; }; | |
66 | print {"a\0b"} "anc"; | |
67 | print {"\0b"} "anc"; | |
68 | EXPECT | |
69 | print() on unopened filehandle a\0b at - line 4. | |
70 | print() on unopened filehandle \0b at - line 5. | |
71 | ######## | |
72 | # pp_hot.c [pp_print] | |
4438c4b7 | 73 | use warnings 'io' ; |
977289e4 NC |
74 | # There is no guarantee that STDOUT is output only, or STDIN input only. |
75 | # Certainly on some BSDs (at least FreeBSD, Darwin, BSDi) file descriptors | |
76 | # 1 and 2 are opened read/write on the tty, and the IO layers may reflect this. | |
77 | # So we must make our own file handle that is read only. | |
78 | my $file = "./xcv" ; unlink $file ; | |
79 | open (FH, ">$file") or die $! ; | |
80 | close FH or die $! ; | |
81 | die "There is no file $file" unless -f $file ; | |
82 | open (FH, "<$file") or die $! ; | |
83 | print FH "anc" ; | |
84 | open(FOO, "<&FH") or die $! ; | |
85 | print FOO "anc" ; | |
37bd1396 | 86 | no warnings 'io' ; |
977289e4 NC |
87 | print FH "anc" ; |
88 | print FOO "anc" ; | |
89 | use warnings 'io' ; | |
90 | print FH "anc" ; | |
91 | print FOO "anc" ; | |
92 | close (FH) or die $! ; | |
93 | close (FOO) or die $! ; | |
94 | unlink $file ; | |
599cee73 | 95 | EXPECT |
977289e4 NC |
96 | Filehandle FH opened only for input at - line 12. |
97 | Filehandle FOO opened only for input at - line 14. | |
98 | Filehandle FH opened only for input at - line 19. | |
99 | Filehandle FOO opened only for input at - line 20. | |
599cee73 | 100 | ######## |
767a6a26 | 101 | # pp_hot.c [pp_print] |
b3c81598 FC |
102 | $SIG{__WARN__} = sub { warn $_[0] =~ s/\0/\\0/rug; }; |
103 | use warnings 'io' ; | |
104 | my $file = "./xcv" ; unlink $file ; | |
105 | open (FH, ">$file") or die $! ; | |
106 | close FH or die $! ; | |
107 | die "There is no file $file" unless -f $file ; | |
108 | open ("a\0b", "<$file") or die $! ; | |
109 | print {"a\0b"} "anc" ; | |
110 | open ("\0b", "<$file") or die $! ; | |
111 | print {"\0b"} "anc" ; | |
112 | close "a\0b" or die $! ; | |
113 | close "\0b" or die $! ; | |
114 | unlink $file ; | |
115 | EXPECT | |
116 | Filehandle a\0b opened only for input at - line 9. | |
117 | Filehandle \0b opened only for input at - line 11. | |
118 | ######## | |
119 | # pp_hot.c [pp_print] | |
4438c4b7 | 120 | use warnings 'closed' ; |
599cee73 PM |
121 | close STDIN ; |
122 | print STDIN "anc"; | |
69282e91 GS |
123 | opendir STDIN, "."; |
124 | print STDIN "anc"; | |
125 | closedir STDIN; | |
4438c4b7 | 126 | no warnings 'closed' ; |
0453d815 | 127 | print STDIN "anc"; |
69282e91 GS |
128 | opendir STDIN, "."; |
129 | print STDIN "anc"; | |
cf26e47f NC |
130 | use warnings; |
131 | no warnings 'closed' ; | |
132 | print STDIN "anc"; | |
599cee73 | 133 | EXPECT |
43693395 GS |
134 | print() on closed filehandle STDIN at - line 4. |
135 | print() on closed filehandle STDIN at - line 6. | |
136 | (Are you trying to call print() on dirhandle STDIN?) | |
599cee73 | 137 | ######## |
f55e507d | 138 | # pp_hot.c [pp_print] |
ee95e30c | 139 | # [ID 20020425.012 (#9030)] from Dave Steiner <steiner@bakerst.rutgers.edu> |
f55e507d NC |
140 | # This goes segv on 5.7.3 |
141 | use warnings 'closed' ; | |
142 | my $fh = *STDOUT{IO}; | |
143 | close STDOUT or die "Can't close STDOUT"; | |
144 | print $fh "Shouldn't print anything, but shouldn't SEGV either\n"; | |
145 | EXPECT | |
885f468a | 146 | print() on closed filehandle __ANONIO__ at - line 7. |
f55e507d | 147 | ######## |
f62cb720 RGS |
148 | # pp_hot.c [pp_print] |
149 | package foo; | |
150 | use warnings 'closed'; | |
151 | open my $fh1, "nonexistent"; | |
152 | print $fh1 42; | |
153 | open $fh2, "nonexistent"; | |
154 | print $fh2 42; | |
155 | open $bar::fh3, "nonexistent"; | |
156 | print $bar::fh3 42; | |
157 | open bar::FH4, "nonexistent"; | |
158 | print bar::FH4 42; | |
159 | EXPECT | |
160 | print() on closed filehandle $fh1 at - line 5. | |
161 | print() on closed filehandle $fh2 at - line 7. | |
162 | print() on closed filehandle $fh3 at - line 9. | |
163 | print() on closed filehandle FH4 at - line 11. | |
164 | ######## | |
767a6a26 | 165 | # pp_hot.c [pp_rv2av] |
4438c4b7 | 166 | use warnings 'uninitialized' ; |
599cee73 | 167 | my $a = undef ; |
0453d815 | 168 | my @b = @$a; |
4438c4b7 | 169 | no warnings 'uninitialized' ; |
0453d815 | 170 | my @c = @$a; |
599cee73 | 171 | EXPECT |
29489e7c | 172 | Use of uninitialized value $a in array dereference at - line 4. |
599cee73 | 173 | ######## |
767a6a26 | 174 | # pp_hot.c [pp_rv2hv] |
4438c4b7 | 175 | use warnings 'uninitialized' ; |
599cee73 | 176 | my $a = undef ; |
0453d815 | 177 | my %b = %$a; |
4438c4b7 | 178 | no warnings 'uninitialized' ; |
0453d815 | 179 | my %c = %$a; |
599cee73 | 180 | EXPECT |
29489e7c | 181 | Use of uninitialized value $a in hash dereference at - line 4. |
599cee73 | 182 | ######## |
767a6a26 | 183 | # pp_hot.c [pp_aassign] |
e476b1b5 | 184 | use warnings 'misc' ; |
599cee73 | 185 | my %X ; %X = (1,2,3) ; |
e476b1b5 | 186 | no warnings 'misc' ; |
0453d815 | 187 | my %Y ; %Y = (1,2,3) ; |
599cee73 PM |
188 | EXPECT |
189 | Odd number of elements in hash assignment at - line 3. | |
190 | ######## | |
767a6a26 | 191 | # pp_hot.c [pp_aassign] |
e476b1b5 | 192 | use warnings 'misc' ; |
599cee73 | 193 | my %X ; %X = [1 .. 3] ; |
e476b1b5 | 194 | no warnings 'misc' ; |
0453d815 | 195 | my %Y ; %Y = [1 .. 3] ; |
599cee73 PM |
196 | EXPECT |
197 | Reference found where even-sized list expected at - line 3. | |
198 | ######## | |
767a6a26 | 199 | # pp_hot.c [Perl_do_readline] |
4438c4b7 | 200 | use warnings 'closed' ; |
69282e91 GS |
201 | close STDIN ; $a = <STDIN> ; |
202 | opendir STDIN, "." ; $a = <STDIN> ; | |
203 | closedir STDIN; | |
4438c4b7 | 204 | no warnings 'closed' ; |
69282e91 | 205 | opendir STDIN, "." ; $a = <STDIN> ; |
0453d815 | 206 | $a = <STDIN> ; |
599cee73 | 207 | EXPECT |
43693395 GS |
208 | readline() on closed filehandle STDIN at - line 3. |
209 | readline() on closed filehandle STDIN at - line 4. | |
210 | (Are you trying to call readline() on dirhandle STDIN?) | |
599cee73 | 211 | ######## |
767a6a26 | 212 | # pp_hot.c [Perl_do_readline] |
d955f84c FC |
213 | use warnings 'closed' ; |
214 | close STDIN ; $a .= <STDIN> ; | |
215 | opendir STDIN, "." ; $a .= <STDIN> ; | |
216 | closedir STDIN; | |
217 | no warnings 'closed' ; | |
218 | opendir STDIN, "." ; $a .= <STDIN> ; | |
219 | $a = <STDIN> ; | |
220 | EXPECT | |
221 | readline() on closed filehandle STDIN at - line 3. | |
222 | readline() on closed filehandle STDIN at - line 4. | |
223 | (Are you trying to call readline() on dirhandle STDIN?) | |
224 | ######## | |
225 | # pp_hot.c [Perl_do_readline] | |
767a6a26 PM |
226 | use warnings 'io' ; |
227 | my $file = "./xcv" ; unlink $file ; | |
977289e4 | 228 | open (FH, ">$file") or die $! ; |
767a6a26 PM |
229 | my $a = <FH> ; |
230 | no warnings 'io' ; | |
231 | $a = <FH> ; | |
977289e4 NC |
232 | use warnings 'io' ; |
233 | open(FOO, ">&FH") or die $! ; | |
234 | $a = <FOO> ; | |
235 | no warnings 'io' ; | |
236 | $a = <FOO> ; | |
237 | use warnings 'io' ; | |
238 | $a = <FOO> ; | |
239 | $a = <FH> ; | |
240 | close (FH) or die $! ; | |
241 | close (FOO) or die $! ; | |
767a6a26 PM |
242 | unlink $file ; |
243 | EXPECT | |
43693395 | 244 | Filehandle FH opened only for output at - line 5. |
977289e4 NC |
245 | Filehandle FOO opened only for output at - line 10. |
246 | Filehandle FOO opened only for output at - line 14. | |
247 | Filehandle FH opened only for output at - line 15. | |
767a6a26 PM |
248 | ######## |
249 | # pp_hot.c [Perl_sub_crush_depth] | |
4438c4b7 | 250 | use warnings 'recursion' ; |
599cee73 PM |
251 | sub fred |
252 | { | |
253 | fred() if $a++ < 200 | |
254 | } | |
4a925ff6 GS |
255 | { |
256 | local $SIG{__WARN__} = sub { | |
257 | die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ | |
258 | }; | |
259 | fred(); | |
260 | } | |
599cee73 | 261 | EXPECT |
4a925ff6 | 262 | ok |
599cee73 | 263 | ######## |
767a6a26 | 264 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 | 265 | no warnings 'recursion' ; |
0453d815 PM |
266 | sub fred |
267 | { | |
268 | fred() if $a++ < 200 | |
269 | } | |
270 | { | |
271 | local $SIG{__WARN__} = sub { | |
272 | die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ | |
273 | }; | |
274 | fred(); | |
275 | } | |
276 | EXPECT | |
277 | ||
278 | ######## | |
767a6a26 | 279 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 | 280 | use warnings 'recursion' ; |
599cee73 PM |
281 | $b = sub |
282 | { | |
283 | &$b if $a++ < 200 | |
284 | } ; | |
285 | ||
286 | &$b ; | |
287 | EXPECT | |
288 | Deep recursion on anonymous subroutine at - line 5. | |
0453d815 | 289 | ######## |
767a6a26 | 290 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 | 291 | no warnings 'recursion' ; |
0453d815 PM |
292 | $b = sub |
293 | { | |
294 | &$b if $a++ < 200 | |
295 | } ; | |
296 | ||
297 | &$b ; | |
298 | EXPECT | |
6bc102ca GS |
299 | ######## |
300 | # pp_hot.c [pp_concat] | |
8d6d96c1 HS |
301 | use warnings 'uninitialized'; |
302 | my($x, $y); | |
303 | sub a { shift } | |
304 | a($x . "x"); # should warn once | |
305 | a($x . $y); # should warn twice | |
306 | $x .= $y; # should warn once | |
307 | $y .= $y; # should warn once | |
308 | EXPECT | |
29489e7c | 309 | Use of uninitialized value $x in concatenation (.) or string at - line 5. |
29489e7c | 310 | Use of uninitialized value $x in concatenation (.) or string at - line 6. |
c75ab21a | 311 | Use of uninitialized value $y in concatenation (.) or string at - line 6. |
29489e7c DM |
312 | Use of uninitialized value $y in concatenation (.) or string at - line 7. |
313 | Use of uninitialized value $y in concatenation (.) or string at - line 8. | |
8d6d96c1 | 314 | ######## |
d804643f SC |
315 | # pp_hot.c [pp_aelem] |
316 | { | |
317 | use warnings 'misc'; | |
318 | print $x[\1]; | |
319 | } | |
320 | { | |
321 | no warnings 'misc'; | |
322 | print $x[\1]; | |
323 | } | |
324 | ||
325 | EXPECT | |
326 | OPTION regex | |
327 | Use of reference ".*" as array index at - line 4. | |
1f1cc344 JH |
328 | ######## |
329 | # pp_hot.c [pp_aelem] | |
330 | package Foo;use overload q("") => sub {};package main;$a = bless {}, "Foo"; | |
331 | $b = {}; | |
332 | { | |
333 | use warnings 'misc'; | |
334 | print $x[$a]; | |
335 | print $x[$b]; | |
336 | } | |
337 | { | |
338 | no warnings 'misc'; | |
339 | print $x[$a]; | |
340 | print $x[$b]; | |
341 | } | |
342 | ||
343 | EXPECT | |
344 | OPTION regex | |
345 | Use of reference ".*" as array index at - line 7. | |
b48c4cba DM |
346 | ######## |
347 | use warnings 'misc'; | |
348 | use constant FOO => { a => 1 }; | |
349 | () = $_[FOO->{a}]; | |
350 | ||
351 | EXPECT | |
352 | ######## | |
353 | use warnings 'misc'; | |
354 | use constant FOO => {}; | |
355 | () = $_[FOO]; | |
356 | ||
357 | EXPECT | |
358 | OPTION regex | |
359 | Use of reference "HASH\(0x\w+\)" as array index at - line 3. |