This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deprecate wide chars in logical string ops
[perl5.git] / t / lib / warnings / pp
CommitLineData
599cee73
PM
1 pp.c TODO
2
3 substr outside of string
e476b1b5 4 $a = "ab" ; $b = substr($a, 4,5) ;
599cee73
PM
5
6 Attempt to use reference as lvalue in substr
7 $a = "ab" ; $b = \$a ; substr($b, 1,1) = $b
8
3b434eb1 9 Use of uninitialized value in scalar dereference [pp_rv2sv()]
599cee73
PM
10 my $a = undef ; my $b = $$a
11
12 Odd number of elements in hash list
13 my $a = { 1,2,3 } ;
14
599cee73
PM
15 Explicit blessing to '' (assuming package main)
16 bless \[], "";
17
3b434eb1
RGS
18 Constant subroutine %s undefined
19 sub foo () { 1 }; undef &foo;
20
21 Constant subroutine (anonymous) undefined
22 $foo = sub () { 3 }; undef &$foo;
0453d815 23
599cee73
PM
24__END__
25# pp.c
4438c4b7 26use warnings 'substr' ;
599cee73 27$a = "ab" ;
e476b1b5 28$b = substr($a, 4,5) ;
4438c4b7 29no warnings 'substr' ;
0453d815 30$a = "ab" ;
e476b1b5 31$b = substr($a, 4,5) ;
599cee73
PM
32EXPECT
33substr outside of string at - line 4.
34########
35# pp.c
4438c4b7 36use warnings 'substr' ;
599cee73
PM
37$a = "ab" ;
38$b = \$a ;
39substr($b, 1,1) = "ab" ;
6582db62
FC
40$b = \$a;
41substr($b, 1,1) = "\x{100}" ;
4438c4b7 42no warnings 'substr' ;
6582db62 43$b = \$a;
0453d815 44substr($b, 1,1) = "ab" ;
6582db62
FC
45$b = \$a;
46substr($b, 1,1) = "\x{100}" ;
599cee73
PM
47EXPECT
48Attempt to use reference as lvalue in substr at - line 5.
6582db62 49Attempt to use reference as lvalue in substr at - line 7.
599cee73
PM
50########
51# pp.c
5cd408a2
EB
52use warnings 'misc' ;
53@a = qw( a b c );
54splice(@a, 4, 0, 'e') ;
55@a = qw( a b c );
56splice(@a, 4, 1) ;
57@a = qw( a b c );
58splice(@a, 4) ;
59no warnings 'misc' ;
60@a = qw( a b c );
61splice(@a, 4, 0, 'e') ;
62@a = qw( a b c );
63splice(@a, 4, 1) ;
64@a = qw( a b c );
65splice(@a, 4) ;
66EXPECT
67splice() offset past end of array at - line 4.
68splice() offset past end of array at - line 6.
69########
70# pp.c
3b434eb1
RGS
71use warnings 'uninitialized';
72$x = undef; $y = $$x;
73no warnings 'uninitialized' ;
74$u = undef; $v = $$u;
75EXPECT
29489e7c 76Use of uninitialized value $x in scalar dereference at - line 3.
599cee73
PM
77########
78# pp.c
e476b1b5 79use warnings 'misc' ;
599cee73 80my $a = { 1,2,3};
e476b1b5 81no warnings 'misc' ;
0453d815 82my $b = { 1,2,3};
599cee73 83EXPECT
b21befc1 84Odd number of elements in anonymous hash at - line 3.
599cee73 85########
599cee73 86# pp.c
e476b1b5 87use warnings 'misc' ;
599cee73 88bless \[], "" ;
e476b1b5 89no warnings 'misc' ;
0453d815 90bless \[], "" ;
599cee73
PM
91EXPECT
92Explicit blessing to '' (assuming package main) at - line 3.
0453d815
PM
93########
94# pp.c
3b434eb1
RGS
95use warnings 'misc';
96sub foo () { 1 }
97undef &foo;
98no warnings 'misc';
99sub bar () { 2 }
100undef &bar;
101EXPECT
102Constant subroutine foo undefined at - line 4.
103########
104# pp.c
714cd18f
BF
105use utf8;
106use open qw( :utf8 :std );
107use warnings 'misc';
108sub ฝᶱ () { 1 }
109undef &ฝᶱ;
110no warnings 'misc';
111sub ƚ () { 2 }
112undef &ƚ;
113EXPECT
114Constant subroutine ฝᶱ undefined at - line 6.
115########
116# pp.c
3b434eb1
RGS
117use warnings 'misc';
118$foo = sub () { 3 };
119undef &$foo;
120no warnings 'misc';
121$bar = sub () { 4 };
122undef &$bar;
123EXPECT
124Constant subroutine (anonymous) undefined at - line 4.
125########
126# pp.c
0453d815
PM
127use utf8 ;
128$_ = "\x80 \xff" ;
129reverse ;
130EXPECT
87e05d1a
KW
131########
132# NAME deprecation of complement with above ff code points
133$_ = ~ "\xff";
134$_ = ~ "\x{100}";
135EXPECT
136OPTION regex
137Use of strings with code points over 0xFF as arguments to 1's complement \(~\) operator is deprecated at - line \d+.
138Use of code point 0xFF+EFF is deprecated; the permissible max is 0x7F+ at - line \d+.