www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2195] New: Variable shadowing is not detected and reported

reply d-bugmail puremagic.com writes:
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
    }
}


-- 
Jul 05 2008
next sibling parent d-bugmail puremagic.com writes:
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



*** 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: -------
Aug 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Aug 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2195


Don <clugdbug yahoo.com.au> changed:

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




 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: -------
Aug 31 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2195






 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: -------
Aug 31 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2195







 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: -------
Aug 31 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jan 29 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Aug 24 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2195





 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: -------
Oct 28 2012