[D2] const vs structs

Richard Webb webby at beardmouse.org.uk
Thu Dec 10 16:23:43 PST 2009


I just tried to build the Juno library with DMD 2.037, and got a bunch or errors like:

juno\com\core.d(295): Error: function juno.com.core.GUID.opEquals type signature should be const bool(ref const(GUID)) not bool(GUID other)

Which can be replicated with:
////////////////////////////////
struct Foo
{
	bool opEquals(Foo f) const
	{
		return true;
	}
}

void Bar()
{
	Foo f;
}
////////////////////////////////

It built ok with DMD2 a few months ago. Is this an intentional change?

Also, while looking at the problem i noticed that code like:

////////////////////////////////
struct Foo
{
	~this()
	{
		
	}
}

void Bar()
{
	const Foo f;
}
////////////////////////////////

Produces the error:

Error: destructor Foo.~this () is not callable using argument types ()

which seems a bit wrong?

Thanks,
Richard Webb


More information about the Digitalmars-d-learn mailing list