Skip to content

Commit 12c45b2

Browse files
author
Father Chrysostomos
committed
Fix assertion failure with $float = $regexp assignment
Commit b9ad13a caused case SVt_REGEXP in sv_upgrade to fall through to the assertions under case SVt_PVIV that are not relevant to SVt_REGEXP. We should really be setting the FAKE flag when actually making a sca- lar a regexp, rather than in sv_upgrade. (I will probably need it there in future commits, too, since it really should be possible for SVt_PVLVs to hold regular expressions.)
1 parent 093085a commit 12c45b2

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

regcomp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14178,6 +14178,9 @@ Perl_reg_temp_copy (pTHX_ REGEXP *ret_x, REGEXP *rx)
1417814178

1417914179
if (!ret_x)
1418014180
ret_x = (REGEXP*) newSV_type(SVt_REGEXP);
14181+
/* This ensures that SvTHINKFIRST(sv) is true, and hence that
14182+
sv_force_normal(sv) is called. */
14183+
SvFAKE_on(ret_x);
1418114184
ret = (struct regexp *)SvANY(ret_x);
1418214185

1418314186
(void)ReREFCNT_inc(rx);

sv.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,11 +1329,6 @@ Perl_sv_upgrade(pTHX_ register SV *const sv, svtype new_type)
13291329
}
13301330
break;
13311331

1332-
1333-
case SVt_REGEXP:
1334-
/* This ensures that SvTHINKFIRST(sv) is true, and hence that
1335-
sv_force_normal_flags(sv) is called. */
1336-
SvFAKE_on(sv);
13371332
case SVt_PVIV:
13381333
/* XXX Is this still needed? Was it ever needed? Surely as there is
13391334
no route from NV to PVIV, NOK can never be true */
@@ -1344,6 +1339,7 @@ Perl_sv_upgrade(pTHX_ register SV *const sv, svtype new_type)
13441339
case SVt_PVGV:
13451340
case SVt_PVCV:
13461341
case SVt_PVLV:
1342+
case SVt_REGEXP:
13471343
case SVt_PVMG:
13481344
case SVt_PVNV:
13491345
case SVt_PV:

t/op/qr.t

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ BEGIN {
77
require './test.pl';
88
}
99

10-
plan(tests => 20);
10+
plan(tests => 21);
1111

1212
sub r {
1313
return qr/Good/;
@@ -67,3 +67,8 @@ like "bar",qr//,'[perl #96230] =~ qr// does not reuse last successful pat';
6767
$_ = "bar";
6868
$_ =~ s/${qr||}/baz/;
6969
is $_, "bazbar", '[perl #96230] s/$qr// does not reuse last pat';
70+
71+
{
72+
my $x = 1.1; $x = ${qr//};
73+
pass 'no assertion failure when upgrading NV to regexp';
74+
}

0 commit comments

Comments
 (0)