D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10500 - Problem with length property when using variant
Summary: Problem with length property when using variant
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-29 04:04 UTC by Justinas Šneideris
Modified: 2015-06-09 05:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Justinas Šneideris 2013-06-29 04:04:57 UTC
void main()
{
	struct Vector
	{
		float length();
	}

	import std.variant;
	Variant v = Vector();
}

Currently this does not work, as it seems Variant thinks length() 
is a property restricted to arrays.

"cannot implicitly convert expression ((*zis).length()) of type 
float to int	C:\D\dmd2\src\phobos\std\variant.d	488"

I quickly changed that line in variant.do to "static if 
(is(typeof(zis.length)) && is(ReturnType!(zis.length) == 
size_t))" and my code compiles.

Currently its a hack, but should it be more developed and would 
it not interfere with something else?
Comment 1 Kapps 2014-07-22 04:42:49 UTC
Fixed by yglukhov in https://github.com/D-Programming-Language/phobos/pull/2062.