www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - std.Variant issues

The following program fails:

import std.stdio;
import std.variant;

Variant a;
Variant b;

void main ()
{
	a=2;
	b=3;
	writeln(b-a);
}


With the error:

testar.d(11): Error: overloads VariantN!(maxSize)(VariantN!(maxSize)
rhs) and VariantN!(maxSize)(VariantN!(maxSize)
  lhs) both match argument list for opSub


Also:

a="3";
writeln(a.coerce!(int)());

compiles successfully but does not run:
Error: Variant: attempting to use incompatible types invariant(char)[]
and real

even though the documentation states it shouldn't fail:

If the VariantN object is a string, a parse of the string to type T is 
attempted. If a conversion is not possible, throws a VariantException.

And lastly, the documentation states that a VariantException is thrown, 
but the output shows an "Error", not an Exception.

Is this a bug that needs to be filed? Or is it me that misunderstood 
something?
Mar 21 2008