Thread overview
[Issue 7694] New: Internal error: e2ir.c 1251 when calling member function inside struct via alias param
Mar 12, 2012
Dmitry Olshansky
Mar 22, 2012
Dmitry Olshansky
Mar 24, 2012
Kenji Hara
Mar 24, 2012
Kenji Hara
Mar 24, 2012
Dmitry Olshansky
Mar 29, 2012
Walter Bright
March 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7694

           Summary: Internal error: e2ir.c 1251 when calling member
                    function inside struct via alias param
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: dmitry.olsh@gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-03-12 12:42:51 PDT ---
As is the following gives assert on line 8 as expected, uncomment bootstrap to get Internal error: e2ir.c 1251

template Instruction(int ir)
{
    void match(alias s, alias  m)(){ m.nextState(); }
}


struct T{
    void nextState(){  assert(0); }
/*    void bootstrap()
    {
    return Instruction!(0).match!(this, this)();
    }*/
}

T t;
void main()
{

//  t.bootstrap();
  Instruction!(0).match!(t, t)();
}

on dmd 2.059head win7 x64
last commit: bcfd90aae05bd6259212ec870b2c037569029d77

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



--- Comment #1 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-03-22 12:34:05 PDT ---
Minimized test case and a workaround:

void match(alias m)(){
    m.foo();//removing this line supresses ice in both cases
}

struct T{
    void foo(){}
    void bootstrap()
    {
//next line causes ice
//        match!(this)();
//while this works:
    alias this p;
        match!(p)();

    }
}

void main(){}


Apaaerntly it has something to do with plain 'this' being mistreated in when passed as alias.

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


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

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


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-23 22:38:49 PDT ---
https://github.com/D-Programming-Language/dmd/pull/827

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



--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-23 22:50:19 PDT ---
(In reply to comment #0)
> As is the following gives assert on line 8 as expected, uncomment bootstrap to get Internal error: e2ir.c 1251
> 
> template Instruction(int ir)
> {
>     void match(alias s, alias  m)(){ m.nextState(); }
> }
> 
> 
> struct T{
>     void nextState(){  assert(0); }
> /*    void bootstrap()
>     {
>     return Instruction!(0).match!(this, this)();
>     }*/
> }
> 
> T t;
> void main()
> {
> 
> //  t.bootstrap();
>   Instruction!(0).match!(t, t)();
> }

With my pull, this code doesn't report ice, but raises following errors:

test.d(11): Error: template instance match!(this,this) cannot use local 'this'
as parameter to non-global template match(alias s,alias m)
test.d(11): Error: template instance match!(this,this) cannot use local 'this'
as parameter to non-global template match(alias s,alias m)

But I think this is a little harsh error. The nested template (function) match in module template Instruction really needs only one context, that is enclosing 'this' given as alias parameters m and n.

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



--- Comment #4 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-03-24 14:28:17 PDT ---
I think the error is tolerable, when I found workaround I just rewrote it to global template. Less flexible maybe, but works for me.

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



--- Comment #5 from github-bugzilla@puremagic.com 2012-03-28 20:02:46 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f8d472fed64a174472832d919f65b811fca0a968 Merge pull request #827 from 9rnsr/fix7694

Issue 7694 - Internal error: e2ir.c 1251 when calling member function inside struct via alias param

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


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