Commit | Line | Data |
767a6a26 |
1 | pp_hot.c |
599cee73 |
2 | |
2dd78f96 |
3 | print() on unopened filehandle abc [pp_print] |
599cee73 |
4 | $f = $a = "abc" ; print $f $a |
5 | |
767a6a26 |
6 | Filehandle %s opened only for input [pp_print] |
599cee73 |
7 | print STDIN "abc" ; |
8 | |
767a6a26 |
9 | Filehandle %s opened only for output [pp_print] |
af8c498a |
10 | print <STDOUT> ; |
599cee73 |
11 | |
9a7dcd9c |
12 | print() on closed filehandle %s [pp_print] |
599cee73 |
13 | close STDIN ; print STDIN "abc" ; |
14 | |
767a6a26 |
15 | uninitialized [pp_rv2av] |
599cee73 |
16 | my $a = undef ; my @b = @$a |
17 | |
767a6a26 |
18 | uninitialized [pp_rv2hv] |
599cee73 |
19 | my $a = undef ; my %b = %$a |
20 | |
767a6a26 |
21 | Odd number of elements in hash list [pp_aassign] |
599cee73 |
22 | %X = (1,2,3) ; |
23 | |
767a6a26 |
24 | Reference found where even-sized list expected [pp_aassign] |
599cee73 |
25 | $X = [ 1 ..3 ]; |
26 | |
767a6a26 |
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 |
34 | close STDIN ; $a = <STDIN>; |
35 | |
790090df |
36 | readline() on closed filehandle %s [Perl_do_readline] |
37 | readline(NONESUCH); |
38 | |
767a6a26 |
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 | |
6bc102ca |
47 | Possible Y2K bug: about to append an integer to '19' [pp_concat] |
48 | $x = "19$yy\n"; |
767a6a26 |
49 | |
d804643f |
50 | Use of reference "%s" as array index [pp_aelem] |
51 | $x[\1] |
52 | |
599cee73 |
53 | __END__ |
767a6a26 |
54 | # pp_hot.c [pp_print] |
4438c4b7 |
55 | use warnings 'unopened' ; |
599cee73 |
56 | $f = $a = "abc" ; |
0453d815 |
57 | print $f $a; |
4438c4b7 |
58 | no warnings 'unopened' ; |
0453d815 |
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] |
4438c4b7 |
64 | use warnings 'io' ; |
599cee73 |
65 | print STDIN "anc"; |
af8c498a |
66 | print <STDOUT>; |
67 | print <STDERR>; |
68 | open(FOO, ">&STDOUT") and print <FOO>; |
69 | print getc(STDERR); |
70 | print getc(FOO); |
ea1135d6 |
71 | #################################################################### |
72 | # The next test is known to fail on some systems (Linux+old glibc, # |
38e81d60 |
73 | # some *BSDs (including Mac OS X and NeXT), among others. # |
ea1135d6 |
74 | # We skip it for now (on the grounds that it is "just" a warning). # |
75 | #################################################################### |
37bd1396 |
76 | #read(FOO,$_,1); |
77 | no warnings 'io' ; |
78 | print STDIN "anc"; |
599cee73 |
79 | EXPECT |
43693395 |
80 | Filehandle STDIN opened only for input at - line 3. |
81 | Filehandle STDOUT opened only for output at - line 4. |
82 | Filehandle STDERR opened only for output at - line 5. |
83 | Filehandle FOO opened only for output at - line 6. |
84 | Filehandle STDERR opened only for output at - line 7. |
85 | Filehandle FOO opened only for output at - line 8. |
599cee73 |
86 | ######## |
767a6a26 |
87 | # pp_hot.c [pp_print] |
4438c4b7 |
88 | use warnings 'closed' ; |
599cee73 |
89 | close STDIN ; |
90 | print STDIN "anc"; |
69282e91 |
91 | opendir STDIN, "."; |
92 | print STDIN "anc"; |
93 | closedir STDIN; |
4438c4b7 |
94 | no warnings 'closed' ; |
0453d815 |
95 | print STDIN "anc"; |
69282e91 |
96 | opendir STDIN, "."; |
97 | print STDIN "anc"; |
599cee73 |
98 | EXPECT |
43693395 |
99 | print() on closed filehandle STDIN at - line 4. |
100 | print() on closed filehandle STDIN at - line 6. |
101 | (Are you trying to call print() on dirhandle STDIN?) |
599cee73 |
102 | ######## |
767a6a26 |
103 | # pp_hot.c [pp_rv2av] |
4438c4b7 |
104 | use warnings 'uninitialized' ; |
599cee73 |
105 | my $a = undef ; |
0453d815 |
106 | my @b = @$a; |
4438c4b7 |
107 | no warnings 'uninitialized' ; |
0453d815 |
108 | my @c = @$a; |
599cee73 |
109 | EXPECT |
b89fed5f |
110 | Use of uninitialized value in array dereference at - line 4. |
599cee73 |
111 | ######## |
767a6a26 |
112 | # pp_hot.c [pp_rv2hv] |
4438c4b7 |
113 | use warnings 'uninitialized' ; |
599cee73 |
114 | my $a = undef ; |
0453d815 |
115 | my %b = %$a; |
4438c4b7 |
116 | no warnings 'uninitialized' ; |
0453d815 |
117 | my %c = %$a; |
599cee73 |
118 | EXPECT |
b89fed5f |
119 | Use of uninitialized value in hash dereference at - line 4. |
599cee73 |
120 | ######## |
767a6a26 |
121 | # pp_hot.c [pp_aassign] |
e476b1b5 |
122 | use warnings 'misc' ; |
599cee73 |
123 | my %X ; %X = (1,2,3) ; |
e476b1b5 |
124 | no warnings 'misc' ; |
0453d815 |
125 | my %Y ; %Y = (1,2,3) ; |
599cee73 |
126 | EXPECT |
127 | Odd number of elements in hash assignment at - line 3. |
128 | ######## |
767a6a26 |
129 | # pp_hot.c [pp_aassign] |
e476b1b5 |
130 | use warnings 'misc' ; |
599cee73 |
131 | my %X ; %X = [1 .. 3] ; |
e476b1b5 |
132 | no warnings 'misc' ; |
0453d815 |
133 | my %Y ; %Y = [1 .. 3] ; |
599cee73 |
134 | EXPECT |
135 | Reference found where even-sized list expected at - line 3. |
136 | ######## |
767a6a26 |
137 | # pp_hot.c [Perl_do_readline] |
4438c4b7 |
138 | use warnings 'closed' ; |
69282e91 |
139 | close STDIN ; $a = <STDIN> ; |
140 | opendir STDIN, "." ; $a = <STDIN> ; |
141 | closedir STDIN; |
4438c4b7 |
142 | no warnings 'closed' ; |
69282e91 |
143 | opendir STDIN, "." ; $a = <STDIN> ; |
0453d815 |
144 | $a = <STDIN> ; |
599cee73 |
145 | EXPECT |
43693395 |
146 | readline() on closed filehandle STDIN at - line 3. |
147 | readline() on closed filehandle STDIN at - line 4. |
148 | (Are you trying to call readline() on dirhandle STDIN?) |
599cee73 |
149 | ######## |
767a6a26 |
150 | # pp_hot.c [Perl_do_readline] |
151 | use warnings 'io' ; |
152 | my $file = "./xcv" ; unlink $file ; |
153 | open (FH, ">./xcv") ; |
154 | my $a = <FH> ; |
155 | no warnings 'io' ; |
156 | $a = <FH> ; |
4a52322c |
157 | close (FH) ; |
767a6a26 |
158 | unlink $file ; |
159 | EXPECT |
43693395 |
160 | Filehandle FH opened only for output at - line 5. |
767a6a26 |
161 | ######## |
162 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
163 | use warnings 'recursion' ; |
599cee73 |
164 | sub fred |
165 | { |
166 | fred() if $a++ < 200 |
167 | } |
4a925ff6 |
168 | { |
169 | local $SIG{__WARN__} = sub { |
170 | die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ |
171 | }; |
172 | fred(); |
173 | } |
599cee73 |
174 | EXPECT |
4a925ff6 |
175 | ok |
599cee73 |
176 | ######## |
767a6a26 |
177 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
178 | no warnings 'recursion' ; |
0453d815 |
179 | sub fred |
180 | { |
181 | fred() if $a++ < 200 |
182 | } |
183 | { |
184 | local $SIG{__WARN__} = sub { |
185 | die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ |
186 | }; |
187 | fred(); |
188 | } |
189 | EXPECT |
190 | |
191 | ######## |
767a6a26 |
192 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
193 | use warnings 'recursion' ; |
599cee73 |
194 | $b = sub |
195 | { |
196 | &$b if $a++ < 200 |
197 | } ; |
198 | |
199 | &$b ; |
200 | EXPECT |
201 | Deep recursion on anonymous subroutine at - line 5. |
0453d815 |
202 | ######## |
767a6a26 |
203 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
204 | no warnings 'recursion' ; |
0453d815 |
205 | $b = sub |
206 | { |
207 | &$b if $a++ < 200 |
208 | } ; |
209 | |
210 | &$b ; |
211 | EXPECT |
6bc102ca |
212 | ######## |
213 | # pp_hot.c [pp_concat] |
8d6d96c1 |
214 | use warnings 'uninitialized'; |
215 | my($x, $y); |
216 | sub a { shift } |
217 | a($x . "x"); # should warn once |
218 | a($x . $y); # should warn twice |
219 | $x .= $y; # should warn once |
220 | $y .= $y; # should warn once |
221 | EXPECT |
222 | Use of uninitialized value in concatenation (.) or string at - line 5. |
223 | Use of uninitialized value in concatenation (.) or string at - line 6. |
224 | Use of uninitialized value in concatenation (.) or string at - line 6. |
225 | Use of uninitialized value in concatenation (.) or string at - line 7. |
226 | Use of uninitialized value in concatenation (.) or string at - line 8. |
227 | ######## |
228 | # pp_hot.c [pp_concat] |
e476b1b5 |
229 | use warnings 'y2k'; |
6bc102ca |
230 | use Config; |
231 | BEGIN { |
232 | unless ($Config{ccflags} =~ /Y2KWARN/) { |
233 | print "SKIPPED\n# perl not built with -DPERL_Y2KWARN"; |
234 | exit 0; |
235 | } |
236 | } |
237 | my $x; |
238 | my $yy = 78; |
239 | $x = "19$yy\n"; |
240 | $x = "19" . $yy . "\n"; |
241 | $x = "319$yy\n"; |
242 | $x = "319" . $yy . "\n"; |
777b0c87 |
243 | $yy = 19; |
244 | $x = "ok $yy\n"; |
245 | $yy = 9; |
246 | $x = 1 . $yy; |
e476b1b5 |
247 | no warnings 'y2k'; |
6bc102ca |
248 | $x = "19$yy\n"; |
249 | $x = "19" . $yy . "\n"; |
250 | EXPECT |
251 | Possible Y2K bug: about to append an integer to '19' at - line 12. |
252 | Possible Y2K bug: about to append an integer to '19' at - line 13. |
d804643f |
253 | ######## |
254 | # pp_hot.c [pp_aelem] |
255 | { |
256 | use warnings 'misc'; |
257 | print $x[\1]; |
258 | } |
259 | { |
260 | no warnings 'misc'; |
261 | print $x[\1]; |
262 | } |
263 | |
264 | EXPECT |
265 | OPTION regex |
266 | Use of reference ".*" as array index at - line 4. |
1f1cc344 |
267 | ######## |
268 | # pp_hot.c [pp_aelem] |
269 | package Foo;use overload q("") => sub {};package main;$a = bless {}, "Foo"; |
270 | $b = {}; |
271 | { |
272 | use warnings 'misc'; |
273 | print $x[$a]; |
274 | print $x[$b]; |
275 | } |
276 | { |
277 | no warnings 'misc'; |
278 | print $x[$a]; |
279 | print $x[$b]; |
280 | } |
281 | |
282 | EXPECT |
283 | OPTION regex |
284 | Use of reference ".*" as array index at - line 7. |