Thread overview
[Issue 6317] New: A inner struct with member function causes a compiler internal error
Jul 14, 2011
Heromyth
[Issue 6317] ICE on struct literal of nested struct
Jul 14, 2011
yebblies
Jul 14, 2011
yebblies
Jul 15, 2011
Walter Bright
July 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6317

           Summary: A inner struct with member function causes a compiler
                    internal error
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bitworld@qq.com


--- Comment #0 from Heromyth <bitworld@qq.com> 2011-07-14 07:18:58 PDT ---
If "struct Relative" is defined at the outer of doTest(), everything is OK.

Here are the test codes:
=====================================
import std.stdio;

void doTest()
{
    struct Relative
    {
        int xBase;
        int xDir;

        // This method causes a compiler internal error
        void MoveTo()
        {
        }
    }

    Relative rel = {1, 2};
}

int main(string[] args)
{
    return 0;
}
=====================================

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6317


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |yebblies@gmail.com
           Platform|x86                         |All
            Summary|A inner struct with member  |ICE on struct literal of
                   |function causes a compiler  |nested struct
                   |internal error              |
         OS/Version|Windows                     |All
           Severity|normal                      |critical


--- Comment #1 from yebblies <yebblies@gmail.com> 2011-07-15 00:44:22 EST ---
This fails for both kinds of struct initializers, Struct(...) and {...}. Workaround is to use a static struct and pass the context as needed.

Thanks for reducing this!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6317


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from yebblies <yebblies@gmail.com> 2011-07-15 02:13:52 EST ---
Even simple workaround - use structname(args) instead of { args }.

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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6317


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2011-07-15 12:25:28 PDT ---
https://github.com/D-Programming-Language/dmd/commit/523a8c91a0761543a8757b99e3e3d9fe2fe993e2

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