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
Incorrect scoping of if(){}else{} #1068
Comments
From mjtg@cus.cam.ac.ukproduces spurious warnings "my" variable $x masks earlier declaration in same scope at - line 2. Mike Guy % perl -V Characteristics of this binary (from libperl): |
From [Unknown Contact. See original ticket]On Sat, Jan 22, 2000 at 02:25:00PM +0000, M.J.T. Guy wrote:
The only reason why I would use if (my $x = 1, 0) is precisely to get it -- |
From @TimToadyBart Schuller writes: I think the point of it is that the first declaration is within an { my $x; and it isn't. That being said, I'm not sure we should remove the warning, since the But the message is still slightly false. Larry |
From @gsarOn Sat, 22 Jan 2000 10:14:05 PST, Larry Wall wrote:
I recall my original reasoning was that people wouldn't be declaring a while (my $x = foo()) { and the like. So here's a patch. Sarathy Inline Patch-----------------------------------8<-----------------------------------
Change 4847 by gsar@auger on 2000/01/23 04:47:25
don't warn about masked lexical in C<if (my $x = 1) { my $x; }>,
C<while (my $x = foo()) { my $x = bar(); }> etc.
Affected files ...
... //depot/perl/op.c#241 edit
Differences ...
==== //depot/perl/op.c#241 (text) ====
Index: perl/op.c
--- perl/op.c.~1~ Sat Jan 22 20:56:09 2000
+++ perl/op.c Sat Jan 22 20:56:09 2000
@@ -2008,12 +2008,11 @@
int retval = PL_savestack_ix;
SAVEI32(PL_comppad_name_floor);
- if (full) {
- if ((PL_comppad_name_fill = AvFILLp(PL_comppad_name)) > 0)
- PL_comppad_name_floor = PL_comppad_name_fill;
- else
- PL_comppad_name_floor = 0;
- }
+ PL_comppad_name_floor = AvFILLp(PL_comppad_name);
+ if (full)
+ PL_comppad_name_fill = PL_comppad_name_floor;
+ if (PL_comppad_name_floor < 0)
+ PL_comppad_name_floor = 0;
SAVEI32(PL_min_intro_pending);
SAVEI32(PL_max_intro_pending);
PL_min_intro_pending = 0;
@@ -2028,8 +2027,6 @@
PL_compiling.cop_warnings = newSVsv(PL_compiling.cop_warnings) ;
SAVEFREESV(PL_compiling.cop_warnings) ;
}
-
-
return retval;
}
End of Patch. |
Migrated from rt.perl.org#2020 (status was 'resolved')
Searchable as RT2020$
The text was updated successfully, but these errors were encountered: