Thread overview
[Issue 5094] New: No implicit conversion with "alias property this"
Oct 21, 2010
Shin Fujishiro
Oct 21, 2010
Shin Fujishiro
Dec 06, 2010
Walter Bright
October 21, 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@puremagic.com
        ReportedBy: rsinfu@gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu@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: -------
October 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5094



--- Comment #1 from Shin Fujishiro <rsinfu@gmail.com> 2010-10-21 10:07:27 PDT ---
Created an attachment (id=789)
Patch against dmd r725, fixes implicitConvTo()

implicitConvTo() of TypeStruct and TypeClass don't deal with functions, and just tests convertion from function type to value type (then fails).  The attached patch fixes the problem by adding a special check for functions. Passed dmd/druntime/phobos tests.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 06, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5094


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2010-12-06 00:20:04 PST ---
http://www.dsource.org/projects/dmd/changeset/786

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