www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - a problem with lvalues and opEquals

reply BCS <BCS_member pathlink.com> writes:
struct P
{
real x;

int opEquals(P v)	{return fr(v) >= 0.999999;}

static P Set(real xf)	{P ret;  ret.x=xf; return ret;}

static const P NaN =	{x:real.nan};

real fr(P v)		{return x*v.x;}

P fP(P v)
{
if(1)			// line 15
return P.NaN;	// line 16
return v;		// line 17
}

unittest
{
P X = Set(1);
assert(X.fP(X) == X);	// line 23
}
};

/***
compiled with: dmd lib/pm.d -unittest -c -inline

w/ line 15:
lib/pm.d(23): X.fP(X) is not an lvalue

w/o line 15:
no errors

I'm stumped. Should this work??
*/
Jul 28 2005
parent reply Sean Kelly <sean f4.ca> writes:
This works fine for me with DMD .128.


Sean
Jul 28 2005
parent BCS <BCS_member pathlink.com> writes:
In article <dcbfis$2r6p$1 digitaldaemon.com>, Sean Kelly says...
This works fine for me with DMD .128.


Sean

Jul 29 2005