Why does partial ordering of overloaded functions not take return type into account?

Jeremy DeHaan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 19 19:24:45 PST 2016


module main;

struct ThingOne
{
	int thing = 1;
}

struct ThingTwo
{
  	float thing = 2;
}


struct Test
{
	 ThingOne thing()
  	{
		 return ThingOne();
	}
	
	ThingTwo thing()
	{
		return ThingTwo();
	}

}


void main()
{
	Test test;

	ThingOne thingOne = test.thing();
}


test.d(35): Error: main.Test.thing called with argument types () 
matches both:
test.d(17):     main.Test.thing()
and:
test.d(22):     main.Test.thing()

Why isn't the return type checked when resolving this? Only one 
of the choices would actually compile so there should be no 
ambiguity.


More information about the Digitalmars-d-learn mailing list