summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-03-05 17:25:26 -0700
committerKarl Williamson <khw@cpan.org>2020-03-11 16:09:43 -0600
commit245e10a6f8587fc73d986c2e36c5b4e981553842 (patch)
tree801705e7c4f145e69ba33f4f0ca51ed3b49f10d6
parent71562af6e946a38bf57b167ac53ea5d1fda899ca (diff)
downloadperl-245e10a6f8587fc73d986c2e36c5b4e981553842.tar.gz
use re qw(debug foo) should warn
Instead, foo was silently ignored
-rw-r--r--ext/re/re.pm11
-rw-r--r--ext/re/t/re.t6
2 files changed, 14 insertions, 3 deletions
diff --git a/ext/re/re.pm b/ext/re/re.pm
index 0454c41734..98999a0d68 100644
--- a/ext/re/re.pm
+++ b/ext/re/re.pm
@@ -122,6 +122,7 @@ sub bits {
my $bits = 0;
my $turning_all_off = ! @_ && ! $on;
my $seen_Debug = 0;
+ my $seen_debug = 0;
if ($turning_all_off) {
# Pretend were called with certain parameters, which are best dealt
@@ -166,7 +167,7 @@ sub bits {
${^RE_DEBUG_FLAGS} = $flags{'EXECUTE'} | $flags{'DUMP'};
setcolor() if $s =~/color/i;
_load_unload($on);
- last;
+ $seen_debug = 1;
} elsif (exists $bitmask{$s}) {
$bits |= $bitmask{$s};
} elsif ($EXPORT_OK{$s}) {
@@ -275,9 +276,15 @@ sub bits {
: ($^H &= ~$flags_hint);
} else {
require Carp;
- Carp::carp("Unknown \"re\" subpragma '$s' (known ones are: ",
+ if ($seen_debug && defined $flags{$s}) {
+ Carp::carp("Use \"Debug\" not \"debug\", to list debug types"
+ . " in \"re\". \"$s\" ignored");
+ }
+ else {
+ Carp::carp("Unknown \"re\" subpragma '$s' (known ones are: ",
join(', ', map {qq('$_')} 'debug', 'debugcolor', sort keys %bitmask),
")");
+ }
}
}
diff --git a/ext/re/t/re.t b/ext/re/t/re.t
index 353ff812d4..ff5cf9fa35 100644
--- a/ext/re/t/re.t
+++ b/ext/re/t/re.t
@@ -13,7 +13,7 @@ use strict;
my $re_taint_bit = 0x00100000;
my $re_eval_bit = 0x00200000;
-use Test::More tests => 15;
+use Test::More tests => 16;
require_ok( 're' );
# setcolor
@@ -48,6 +48,10 @@ like( $warn, qr/Unknown "re" subpragma/,
ok( re::bits(0, 'taint') & $re_taint_bit, '... should set taint bits' );
ok( re::bits(0, 'eval') & $re_eval_bit, '... should set eval bits' );
+undef $warn;
+eval "use re qw(debug ALL)";
+like( $warn, qr/"Debug" not "debug"/, 'debug with debugging type should warn');
+
local $^H;
# import