www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9050] New: compiler crash on return type inference

reply d-bugmail puremagic.com writes:
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



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: -------
Nov 20 2012
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Feb 04 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Feb 05 2013
prev sibling parent d-bugmail puremagic.com writes:
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




 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: -------
Feb 05 2013