Thread overview
[Issue 2195] New: Variable shadowing is not detected and reported
Jul 05, 2008
d-bugmail
Aug 19, 2010
Stewart Gordon
Aug 19, 2010
Stewart Gordon
Aug 31, 2010
Don
Aug 31, 2010
Stewart Gordon
Aug 31, 2010
Don
[Issue 2195] Variable shadowing in foreach is not detected and reported
Jan 30, 2012
yebblies
Aug 24, 2012
Michal Minich
Oct 28, 2012
yebblies
July 05, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2195

           Summary: Variable shadowing is not detected and reported
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: 2korden@gmail.com


Test case that fails as of 1.026 (earlist one I have) as well as latest one
(1.031 atm).

void main() {
    int[int] arr;
    int variable;
    foreach (i, j; arr) {
        int variable;  // shadowing is disallowed but not detected
    }
}


-- 

August 19, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2195


Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |smjg@iname.com
         Resolution|                            |DUPLICATE


--- Comment #1 from Stewart Gordon <smjg@iname.com> 2010-08-19 06:28:38 PDT ---
*** This issue has been marked as a duplicate of issue 47 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 19, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2195


Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
            Version|1.00                        |D1 & D2
         Resolution|DUPLICATE                   |
           Severity|normal                      |regression


--- Comment #2 from Stewart Gordon <smjg@iname.com> 2010-08-19 06:37:15 PDT ---
I was wrong, the bug has come back (1.063 and 2.048, Windows).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 31, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2195


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|regression                  |normal


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2010-08-31 02:43:31 PDT ---
(In reply to comment #2)
> I was wrong, the bug has come back (1.063 and 2.048, Windows).

I tested 0.165, 1.000, 1.020, 1.032, 1.041, 1.050, 1.060 and a few others. This is not a regression. The bug was never gone.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 31, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2195



--- Comment #4 from Stewart Gordon <smjg@iname.com> 2010-08-31 04:21:58 PDT ---
(In reply to comment #3)
> (In reply to comment #2)
> > I was wrong, the bug has come back (1.063 and 2.048, Windows).
> 
> I tested 0.165, 1.000, 1.020, 1.032, 1.041, 1.050, 1.060 and a few others. This is not a regression. The bug was never gone.

In that case, any clue why bug 47 was logged as fixed in 0.161, both on the bug page and in the changelog?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 31, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2195



--- Comment #5 from Don <clugdbug@yahoo.com.au> 2010-08-31 04:37:13 PDT ---
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > I was wrong, the bug has come back (1.063 and 2.048, Windows).
> > 
> > I tested 0.165, 1.000, 1.020, 1.032, 1.041, 1.050, 1.060 and a few others. This is not a regression. The bug was never gone.
> 
> In that case, any clue why bug 47 was logged as fixed in 0.161, both on the bug page and in the changelog?

Bug 47 was fixed, and still is. This isn't a duplicate. It applies only with
foreach().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 30, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2195


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com
           Platform|x86                         |All
         OS/Version|Windows                     |All


--- Comment #6 from yebblies <yebblies@gmail.com> 2012-01-30 15:56:24 EST ---
Related to issue 2192.  This only applies when foreach turns the body into a delegate.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2195


Michal Minich <michal.minich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |michal.minich@gmail.com


--- Comment #7 from Michal Minich <michal.minich@gmail.com> 2012-08-24 02:46:04 PDT ---
DMD 2.060

Similar case, where the variable is declared as foreach type list identifier

module main;
int global;
int main (string[] args)
{
    // int global = 10; // Error: shadowing declaration main.main.global
                        // is deprecate .. ok
    foreach (global, item; [1, 2, 3]) // no error reported here for global ..
                                      // but expected
        {}
    writeln(global); // prints 0
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2195



--- Comment #8 from yebblies <yebblies@gmail.com> 2012-10-29 07:38:42 EST ---
(In reply to comment #7)
> DMD 2.060
> 
> Similar case, where the variable is declared as foreach type list identifier
> 
> [snip]

This case is not a bug/not this bug, local variables are allowed to shadow globals.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------