Thread overview
[Issue 5501] New: Variant wrongly assumes that an object's length property returns a size_t
Jan 29, 2011
Nicolas Sicard
Jan 08, 2013
Nicolas Sicard
January 29, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5501

           Summary: Variant wrongly assumes that an object's length
                    property returns a size_t
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: dransic@free.fr


--- Comment #0 from Nicolas Sicard <dransic@free.fr> 2011-01-29 00:59:57 PST ---
The following code doesn't compile. I hit the problem when using std.datetime.Interval (which length returns a Duration).

import std.variant;

struct Foo {
    double length() {
        return double.init;
    }
}

unittest {
    Foo foo;
    Variant v = foo;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 29, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5501


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@metalanguage.com
         AssignedTo|nobody@puremagic.com        |andrei@metalanguage.com


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


Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |INVALID


--- Comment #1 from Andrei Alexandrescu <andrei@erdani.com> 2013-01-08 01:13:47 PST ---
This is by design. The length name is special and defined to return size_t compulsively. A possible solution would be to rename std.datetime.Interval. Will cc jmdavis.

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



--- Comment #2 from Nicolas Sicard <dransic@gmail.com> 2013-01-08 01:22:43 PST ---
(In reply to comment #1)
> This is by design. The length name is special and defined to return size_t compulsively. A possible solution would be to rename std.datetime.Interval. Will cc jmdavis.

I agree. But that makes the length property a quasi-keyword and I think it should be better documented, even if it is already used as such in practice.

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