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
List Constructor Operator - Undefined Values #8079
Comments
From cunger@cas.orgThis is a bug report for perl from cunger@cas.org, The Perl snippet below produces different results under Perl 5.8.4, Perl 5.6.1 (this is what I would have expected if an undefined value Loop 1: 0 Loop 2: 0 Perl 5.8.4 (also same output with Perl 5.8.7): Loop 1: Loop 2: 0 OK, I consider this an application error if you use an undefined Code: #!/usr/local/perl5/bin/perl my @array = (1, 2); # this means $#array is set to 1 for $i ( print "\n"; for $i ( Flags: Site configuration information for perl v5.8.4: Configured by cwu21 at Thu Apr 22 16:01:31 EDT 2004. Summary of my perl5 (revision 5 version 8 subversion 4) configuration: Locally applied patches: @INC for perl v5.8.4: Environment for perl v5.8.4: |
From @ysthOn Fri, Aug 19, 2005 at 01:35:49PM -0700, Chris Unger wrote:
Sounds like a missing mg_get somewhere. |
The RT System itself - Status changed from 'new' to 'open' |
From rick@bort.caOn Fri, Aug 19, 2005 at 05:30:41PM -0700, Yitzchak Scott-Thoennes wrote:
Looks like it might be all over the place. From sv.h: /* Let us hope that bitmaps for UV and IV are the same */ #define SvIV_nomg(sv) (SvIOK(sv) ? SvIVX(sv) : sv_2iv_flags(sv, 0)) Aren't those first three going to return the old un-mg_getted value #define SvIV(sv) sv_2iv(sv) or is it the responsibility of setters to do SvNIOK_off? -- |
From @ysthOn Sat, Aug 20, 2005 at 12:43:03AM -0400, Rick Delaney wrote:
IIRC (don't have time to check the code now), magic only results in |
From rick@bort.caOn Sun, Aug 21, 2005 at 01:00:07AM -0700, Yitzchak Scott-Thoennes wrote:
Ah, thanks. I could have sworn that I saw IOK with Devel::Peek in my -- Inline Patchdiff -rpuN perl-current/pp_ctl.c perl-current-dev/pp_ctl.c
--- perl-current/pp_ctl.c 2005-08-07 06:39:09.000000000 -0400
+++ perl-current-dev/pp_ctl.c 2005-08-21 14:52:48.145320881 -0400
@@ -1843,6 +1843,8 @@ PP(pp_enteriter)
if (SvTYPE(cx->blk_loop.iterary) != SVt_PVAV) {
dPOPss;
SV *right = (SV*)cx->blk_loop.iterary;
+ SvGETMAGIC(sv);
+ SvGETMAGIC(right);
if (RANGE_IS_NUMERIC(sv,right)) {
if ((SvOK(sv) && SvNV(sv) < IV_MIN) ||
(SvOK(right) && SvNV(right) >= IV_MAX))
diff -rpuN perl-current/t/op/range.t perl-current-dev/t/op/range.t
--- perl-current/t/op/range.t 2004-03-18 15:53:32.000000000 -0500
+++ perl-current-dev/t/op/range.t 2005-08-21 14:21:37.127953275 -0400
@@ -7,7 +7,7 @@ BEGIN {
use Config;
-print "1..37\n";
+print "1..45\n";
print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n";
@@ -140,3 +140,51 @@ print join(":", map "[$_]", @foo) eq ''
@foo=(); push @foo, $_ for undef..undef;
print join(":", map "[$_]", @foo) eq '[]' ? "ok 37\n" : "not ok 37\n";
+
+# again with magic
+{
+ my @a = (1..3);
+ @foo=(); push @foo, $_ for undef..$#a;
+ print join(":", @foo) eq '0:1:2' ? "ok 38\n" : "not ok 38\n";
+}
+{
+ my @a = ();
+ @foo=(); push @foo, $_ for $#a..undef;
+ print join(":", @foo) eq '-1:0' ? "ok 39\n" : "not ok 39\n";
+}
+{
+ local $1;
+ "2" =~ /(.+)/;
+ @foo=(); push @foo, $_ for undef..$1;
+ print join(":", @foo) eq '0:1:2' ? "ok 40\n" : "not ok 40\n";
+}
+{
+ local $1;
+ "-2" =~ /(.+)/;
+ @foo=(); push @foo, $_ for $1..undef;
+ print join(":", @foo) eq '-2:-1:0' ? "ok 41\n" : "not ok 41\n";
+}
+{
+ local $1;
+ "B" =~ /(.+)/;
+ @foo=(); push @foo, $_ for undef..$1;
+ print join(":", map "[$_]", @foo) eq '[]' ? "ok 42\n" : "not ok 42\n";
+}
+{
+ local $1;
+ "B" =~ /(.+)/;
+ @foo=(); push @foo, $_ for ""..$1;
+ print join(":", map "[$_]", @foo) eq '[]' ? "ok 43\n" : "not ok 43\n";
+}
+{
+ local $1;
+ "B" =~ /(.+)/;
+ @foo=(); push @foo, $_ for $1..undef;
+ print join(":", map "[$_]", @foo) eq '' ? "ok 44\n" : "not ok 44\n";
+}
+{
+ local $1;
+ "B" =~ /(.+)/;
+ @foo=(); push @foo, $_ for $1.."";
+ print join(":", map "[$_]", @foo) eq '' ? "ok 45\n" : "not ok 45\n";
+} |
@rgs - Status changed from 'open' to 'resolved' |
From @rgsRick Delaney wrote:
Thanks, applied as change #25319. |
Migrated from rt.perl.org#36959 (status was 'resolved')
Searchable as RT36959$
The text was updated successfully, but these errors were encountered: