www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8704] New: Invalid nested struct constructions should be detected

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

           Summary: Invalid nested struct constructions should be detected
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



By fixing issue 8339, invalid accessing to nested struct shows compile error.
But, some cases are still accidentally accepted.

void check(T)()
{
    // nested struct constructions outside valid frame scope
    T t1 = T();
    T t2 = T(1);
}

void main()
{
    struct S
    {
        int n;
        void foo(){}
    }
    check!S();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 21 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8704


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/1133

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 21 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8704


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



08:25:16 PDT ---
What exact rules does the language define for these function-nested types? It
seems arbitrary that some things are allowed while others are not, for example
this works:

void check(T)()
{
    T t = T.init;
    t.foo();
}

void main()
{
    struct S
    {
        int n;
        void foo(){}
    }

    check!S();
}

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