www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4012] New: [CTFE][ICE] auto template function, forward reference error

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

           Summary: [CTFE][ICE] auto template function, forward reference
                    error
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-03-26 13:38:27 PDT ---
Problem found with dmd 2.042. This code works at runtime if you move the enum
line inside the main, but as it is crashes the compiler:


struct Searcher(T) {
    T[] data;
    bool opBinaryRight(string Op:"in")(T item) {
        return false;
    }
}
auto searcher(T)(T[] arr) {
    return Searcher!T(arr);
}
enum bool b = 1 in searcher([1]);
void main() {}


Errors printed:
test.d(10): Error: forward reference to inferred return type of function call
searcher([1])
test.d(10): Error: rvalue of in expression must be an associative array, not
int


(Please add the latest dmd2 version to drop-down menu, I don't know how to do
it).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 26 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4012


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
                 CC|                            |clugdbug yahoo.com.au
            Version|future                      |2.040
           Severity|normal                      |regression


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-03-26 17:14:45 PDT ---
This worked in 2.038, failed in 2.040 and later.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 26 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4012


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #2 from Don <clugdbug yahoo.com.au> 2010-03-29 21:05:56 PDT ---
*** This issue has been marked as a duplicate of issue 3911 ***

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