Linker anomalies

Luh null at null.null
Thu Nov 7 12:14:43 UTC 2019


Hey there,

I figured out some strange behavior ;

#1
It seems that the linker doesn't check for the function declared 
twice first.
Instead, it says:

"Error: class app.Child use of app.Parent.foo() is hidden by 
Child; use alias foo = Parent.foo; to introduce base class 
overload set"

but when we call it ( p.foo() ), then it returns the correct 
error message.

#2
The template update() compiles fine until we call it.

Bizarre, isn't it ?

code:
---
void main()
{
	auto p = new Parent();
	// Shows the wrong error message until uncommented
	//p.foo();
	// Compiles when commented
	//update(p);
}

class Child : Parent
{
	override void foo() { }
}

class Parent
{
	void foo() { }
	void foo() { }
}

void update(T)(T object) if(is(T == Parent))
{
	static if (is(T == Parent))
	{
		// Shouldn't compile
		ObjectThatDoesntExists.bar(T);
	}
}
---

Is this a bug ?


More information about the Digitalmars-d-learn mailing list