[Issue 5094] New: No implicit conversion with "alias property this"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 21 10:06:19 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5094

           Summary: No implicit conversion with "alias property this"
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: rsinfu at gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu at gmail.com> 2010-10-21 10:05:37 PDT ---
Implicit conversion with help of alias this doesn't work if the aliased symbol
is a property (or just nullary) function.  The following code doesn't compile:
--------------------
void main()
{
    S s;
    int[] conv = s; // (4)
}
struct S
{
    @property int[] get() { return [1,2,3]; }
    alias get this;
}
--------------------
% dmd -o- -c test.d
test.d(4): Error: cannot implicitly convert expression (s) of type S to int[]
--------------------
The repro code compiles fine if 'get' is a variable.

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


More information about the Digitalmars-d-bugs mailing list