Thread overview
[Issue 9050] New: compiler crash on return type inference
Nov 20, 2012
Marco Leise
Feb 04, 2013
Andrej Mitrovic
Feb 05, 2013
Marco Leise
[Issue 9050] failing return type inference
Feb 05, 2013
timon.gehr@gmx.ch
November 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9050

           Summary: compiler crash on return type inference
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: ice
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: Marco.Leise@gmx.de


--- Comment #0 from Marco Leise <Marco.Leise@gmx.de> 2012-11-20 08:41:10 PST ---
This is probably some variation of some other bug, but it is hard to tell for
me. In the example below there is a recursive instantiation of foo, A and B. It
takes both calls to foo and the pure attribute to make the compiler crash.
Otherwise it prints:
test.d(4): Error: forward reference to inferred return type of function call
foo(A())
test.d(8): Error: template instance test.B!(int) error instantiating
test.d(10):        instantiated from here: foo!()



struct A(T) {}
struct B(T) {
    unittest {
        foo(A!int());
    }
}
auto foo()(A!int base) pure {
    return B!int();
}
auto l = foo(A!int());

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 04, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9050


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice                         |
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-04 12:38:06 PST ---
Test-case without requiring -unittest:

struct A(T) {}
struct B(T) {
    void f() { foo(A!int()); }
}
auto foo()(A!int base) pure {
    return B!int();
}
auto l = foo(A!int());

void main() { }

The crash is gone in 2.061 so this is no longer an ICE.

Is the return type inference error expected? Otherwise close with WORKSFORME if this was only an ICE report.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9050


Marco Leise <Marco.Leise@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME


--- Comment #2 from Marco Leise <Marco.Leise@gmx.de> 2013-02-05 08:55:25 PST ---
Ok, I don't quite remember what my thoughts were about the return type inference, but it looks valid for the compiler to reject the code. So I followed your advice and set it to resolved.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9050


timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |timon.gehr@gmx.ch
         Resolution|WORKSFORME                  |
            Summary|compiler crash on return    |failing return type
                   |type inference              |inference


--- Comment #3 from timon.gehr@gmx.ch 2013-02-05 09:06:45 PST ---
(In reply to comment #2)
> Ok, I don't quite remember what my thoughts were about the return type inference, but it looks valid for the compiler to reject the code. So I followed your advice and set it to resolved.

No, that is a bug. There is no reason for the compiler to reject the code. (It even works if B is not templated.)

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