Remove the deprecated $# variable
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / pad
CommitLineData
f21d7107 1 pad.c AOK
2
3 "my" variable %s masks earlier declaration in same scope
4 my $x;
5 my $x ;
6
b5c19bd7 7 Variable "%s" will not stay shared
f21d7107 8 sub x {
9 my $x;
10 sub y {
b5c19bd7 11 sub { $x }
f21d7107 12 }
13 }
14
f21d7107 15 sub x {
16 my $x;
17 sub y {
b5c19bd7 18 $x
f21d7107 19 }
20 }
b5c19bd7 21
f21d7107 22 "our" variable %s redeclared (Did you mean "local" instead of "our"?)
23 our $x;
24 {
25 our $x;
26 }
27
28 %s never introduced [pad_leavemy] TODO
29
30__END__
31# pad.c
32use warnings 'misc' ;
33my $x ;
34my $x ;
35my $y = my $y ;
36no warnings 'misc' ;
37my $x ;
38my $y ;
39EXPECT
40"my" variable $x masks earlier declaration in same scope at - line 4.
41"my" variable $y masks earlier declaration in same statement at - line 5.
42########
43# pad.c
f793795c 44use warnings 'misc' ;
45our $x ;
46our $x ;
47our $y = our $y ;
48no warnings 'misc' ;
49our $x ;
50our $y ;
51EXPECT
52"our" variable $x masks earlier declaration in same scope at - line 4.
53"our" variable $y masks earlier declaration in same statement at - line 5.
54########
55# pad.c
56use warnings 'misc' ;
57our $x ;
58my $x ;
59our $y = my $y ;
60no warnings 'misc' ;
61our $z ;
62my $z ;
63our $t = my $t ;
64EXPECT
65"my" variable $x masks earlier declaration in same scope at - line 4.
66"my" variable $y masks earlier declaration in same statement at - line 5.
67########
68# pad.c
69# TODO not implemented yet
70use warnings 'misc' ;
71my $x ;
72our $x ;
73my $y = our $y ;
74no warnings 'misc' ;
75my $z ;
76our $z ;
77my $t = our $t ;
78EXPECT
79"our" variable $x masks earlier declaration in same scope at - line 5.
80"our" variable $y masks earlier declaration in same statement at - line 6.
81########
82# pad.c
f21d7107 83use warnings 'closure' ;
84sub x {
85 my $x;
86 sub y {
87 $x
88 }
89 }
90EXPECT
91Variable "$x" will not stay shared at - line 7.
92########
93# pad.c
94no warnings 'closure' ;
95sub x {
96 my $x;
97 sub y {
98 $x
99 }
100 }
101EXPECT
102
103########
104# pad.c
105use warnings 'closure' ;
106sub x {
b5c19bd7 107 my $x;
f21d7107 108 sub y {
b5c19bd7 109 sub { $x }
f21d7107 110 }
111 }
112EXPECT
b5c19bd7 113Variable "$x" will not stay shared at - line 6.
114########
115# pad.c
116use warnings 'closure' ;
117sub x {
118 my $x;
119 sub {
120 $x;
121 sub y {
122 $x
123 }
124 }->();
125}
126EXPECT
127Variable "$x" will not stay shared at - line 9.
128########
129# pad.c
130use warnings 'closure' ;
131my $x;
132sub {
133 $x;
134 sub f {
135 sub { $x }->();
136 }
137}->();
138EXPECT
f21d7107 139
140########
141# pad.c
142use warnings 'closure' ;
b5c19bd7 143sub {
144 my $x;
145 sub f { $x }
146}->();
147EXPECT
148Variable "$x" is not available at - line 5.
149########
150# pad.c
151use warnings 'closure' ;
152sub {
153 my $x;
154 eval 'sub f { $x }';
155}->();
156EXPECT
157
158########
159# pad.c
160use warnings 'closure' ;
161sub {
162 my $x;
163 sub f { eval '$x' }
164}->();
165f();
166EXPECT
167Variable "$x" is not available at (eval 1) line 2.
168########
169# pad.c
170use warnings 'closure' ;
f21d7107 171sub x {
b5c19bd7 172 our $x;
f21d7107 173 sub y {
b5c19bd7 174 $x
f21d7107 175 }
176 }
177EXPECT
b5c19bd7 178
179########
180# pad.c
181# see bugid 1754
182use warnings 'closure' ;
183sub f {
184 my $x;
185 sub { eval '$x' };
186}
187f()->();
188EXPECT
189Variable "$x" is not available at (eval 1) line 2.
f21d7107 190########
2740392c 191use warnings 'closure' ;
192{
193 my $x = 1;
194 $y = \$x; # force abandonment rather than clear-in-place at scope exit
195 sub f2 { eval '$x' }
196}
197f2();
198EXPECT
199Variable "$x" is not available at (eval 1) line 2.
200########
14f338dc 201use warnings 'closure' ;
202for my $x (1,2,3) {
203 sub f { eval '$x' }
204 f();
205}
206f();
207EXPECT
208Variable "$x" is not available at (eval 4) line 2.
209########
f21d7107 210# pad.c
211no warnings 'closure' ;
212sub x {
213 my $x;
214 sub y {
215 sub { $x }
216 }
217 }
218EXPECT
219
220########
221use warnings 'misc' ;
222our $x;
223{
224 our $x;
225}
226EXPECT
227"our" variable $x redeclared at - line 4.
228 (Did you mean "local" instead of "our"?)
929a0744 229########
230# an our var being introduced should suppress errors about global syms
231use strict;
232use warnings;
233our $x unless $x;
234EXPECT