New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-finite repeat count warning isn't emitted consistently #15929
Comments
From @maukeCreated by @mauke$ perl -wE '$_ = 2 x ("inf" + 0); say "[$_]"' Good. $ perl -wE '$_ = 2 x "inf"; say "[$_]"' No warning here. I think this is a bug because the right operand of x should be Perl Info
|
From @tonycoz
Something like: Inline Patchdiff --git a/pp.c b/pp.c
index 6df2101..2ad4021 100644
--- a/pp.c
+++ b/pp.c
@@ -1804,8 +1804,11 @@ PP(pp_repeat)
count = (IV)nv;
}
}
- else
+ else {
count = SvIV_nomg(sv);
+ if (SvNOKp(sv) && Perl_isinfnan(SvNVX(sv)))
+ infnan = TRUE;
+ }
if (infnan) {
Perl_ck_warner(aTHX_ packWARN(WARN_NUMERIC),
fixes your case, but doesn't help if the count is overloaded: $ ./perl -Ilib -wE '$x = bless {}, "Foo"; say "[", "x" x $x, "]"; package Foo; use overload "0+" => sub { "Inf" };' which I don't see a fix for without making a smarter SvIV() interface. Tony |
The RT System itself - Status changed from 'new' to 'open' |
From zefram@fysh.orgSimilar inconsistent behaviour: $ perl -lwe '@a=qw(aa bb cc); print $a["inf"]; print $a["inf" + 0]' Seems that bare "inf" is zeroish in an integer context, while an "inf" -zefram |
Migrated from rt.perl.org#131050 (status was 'open')
Searchable as RT131050$
The text was updated successfully, but these errors were encountered: