summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op.c7
-rw-r--r--t/lib/strict/subs8
2 files changed, 15 insertions, 0 deletions
diff --git a/op.c b/op.c
index 85ff67b2b6..d633b479cb 100644
--- a/op.c
+++ b/op.c
@@ -2053,6 +2053,13 @@ Perl_bind_match(pTHX_ I32 type, OP *left, OP *right)
desc, sample, sample);
}
+ if (right->op_type == OP_CONST &&
+ cSVOPx(right)->op_private & OPpCONST_BARE &&
+ cSVOPx(right)->op_private & OPpCONST_STRICT)
+ {
+ no_bareword_allowed(right);
+ }
+
if (!(right->op_flags & OPf_STACKED) &&
(right->op_type == OP_MATCH ||
right->op_type == OP_SUBST ||
diff --git a/t/lib/strict/subs b/t/lib/strict/subs
index ed4fe7a443..1e8b0588d8 100644
--- a/t/lib/strict/subs
+++ b/t/lib/strict/subs
@@ -317,3 +317,11 @@ Foo A 1
Foo B 2
Foo C 3
Foo D 4
+########
+
+# Check that barewords on the RHS of a regex match are caught
+use strict;
+"" =~ foo;
+EXPECT
+Bareword "foo" not allowed while "strict subs" in use at - line 4.
+Execution of - aborted due to compilation errors.