File tree Expand file tree Collapse file tree 2 files changed +53
-20
lines changed Expand file tree Collapse file tree 2 files changed +53
-20
lines changed Original file line number Diff line number Diff line change @@ -9,26 +9,46 @@ unless ( __FILE__ =~ /(^|[\/\\])\Q${\__PACKAGE__}\E\.pmc?$/ ) {
9
9
die (" Incorrect use of pragma '${\_ _PACKAGE__}' at $f line $l .\n " );
10
10
}
11
11
12
- my %bitmask = (
13
- refs => 0x00000002,
14
- subs => 0x00000200,
15
- vars => 0x00000400
16
- );
17
- my %explicit_bitmask = (
18
- refs => 0x00000020,
19
- subs => 0x00000040,
20
- vars => 0x00000080
21
- );
12
+ my ( %bitmask , %explicit_bitmask );
13
+
14
+ BEGIN {
15
+ %bitmask = (
16
+ refs => 0x00000002,
17
+ subs => 0x00000200,
18
+ vars => 0x00000400,
19
+ );
20
+
21
+ %explicit_bitmask = (
22
+ refs => 0x00000020,
23
+ subs => 0x00000040,
24
+ vars => 0x00000080,
25
+ );
26
+
27
+ my $bits = 0;
28
+ $bits |= $_ for values %bitmask ;
29
+
30
+ my $inline_all_bits = $bits ;
31
+ *all_bits = sub () { $inline_all_bits };
32
+
33
+ $bits = 0;
34
+ $bits |= $_ for values %explicit_bitmask ;
35
+
36
+ my $inline_all_explicit_bits = $bits ;
37
+ *all_explicit_bits = sub () { $inline_all_explicit_bits };
38
+ }
22
39
23
40
sub bits {
24
41
my $bits = 0;
25
42
my @wrong ;
26
43
foreach my $s (@_ ) {
27
- if (exists $bitmask {$s }) {
28
- $^H |= $explicit_bitmask {$s };
29
- }
30
- else { push @wrong , $s };
31
- $bits |= $bitmask {$s } || 0;
44
+ if (exists $bitmask {$s }) {
45
+ $^H |= $explicit_bitmask {$s };
46
+
47
+ $bits |= $bitmask {$s };
48
+ }
49
+ else {
50
+ push @wrong , $s ;
51
+ }
32
52
}
33
53
if (@wrong ) {
34
54
require Carp;
@@ -37,16 +57,21 @@ sub bits {
37
57
$bits ;
38
58
}
39
59
40
- my @default_bits = qw( refs subs vars) ;
41
-
42
60
sub import {
43
61
shift ;
44
- $^H |= bits( @_ ? @_ : @default_bits ) ;
62
+ $^H |= @_ ? &bits : all_bits | all_explicit_bits ;
45
63
}
46
64
47
65
sub unimport {
48
66
shift ;
49
- $^H &= ~ bits(@_ ? @_ : @default_bits );
67
+
68
+ if (@_ ) {
69
+ $^H &= ~&bits;
70
+ }
71
+ else {
72
+ $^H &= ~all_bits;
73
+ $^H |= all_explicit_bits;
74
+ }
50
75
}
51
76
52
77
1;
Original file line number Diff line number Diff line change 3
3
chdir ' t' if -d ' t' ;
4
4
@INC = ' ../lib' ;
5
5
6
- our $local_tests = 4 ;
6
+ our $local_tests = 6 ;
7
7
require " ../t/lib/common.pl" ;
8
8
9
9
eval qq( use strict 'garbage') ;
@@ -17,3 +17,11 @@ like($@, qr/^Unknown 'strict' tag\(s\) 'foo bar'/);
17
17
18
18
eval qq( no strict qw(foo bar)) ;
19
19
like($@ , qr / ^Unknown 'strict' tag\( s\) 'foo bar'/ );
20
+
21
+ eval ' use v5.12; use v5.10; ${"c"}' ;
22
+ is($@ , ' ' , ' use v5.10 disables implicit strict refs' );
23
+
24
+ eval ' use strict; use v5.10; ${"c"}' ;
25
+ like($@ ,
26
+ qr / ^Can't use string \( "c"\) as a SCALAR ref while "strict refs" in use/ ,
27
+ " use v5.10 doesn't disable explicit strict ref" );
You can’t perform that action at this time.
0 commit comments