www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8017] New: Shadowing declaration not detected when iterating hashes

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8017

           Summary: Shadowing declaration not detected when iterating
                    hashes
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-05-02
16:56:48 PDT ---
int[int] table;

void main()
{
    int foo;
    foreach (a, b; table)
    {
        string foo = "";
    }
}

No error! This happens when iterating hashes. Change the table type to an array
(e.g. int[]) and you'll see the shadowing declaration error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8017


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Shadowing declaration not   |Shadowing declaration not
                   |detected when iterating     |detected in opApply
                   |hashes                      |


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-10-03
20:48:35 PDT ---
Changing title as this seems related to opApply. This passes:

struct Foo
{
    int opApply(int delegate(int, int) dg) { return 1; }
}

void main()
{
    int foo;
    foreach (a, b; Foo())
    {
        string foo = "";
    }
}

foreach on a hash probably expands to some opApply code and we end up with the
same thing as this sample (just a guess though).

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