Linker anomalies
user5678
user5678 at 1234.de
Fri Nov 8 00:19:36 UTC 2019
On Thursday, 7 November 2019 at 12:14:43 UTC, Luh wrote:
> 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 ?
The diagnostic might be bad but at least the compiler doesn't
crash, yay, woohoo !
More information about the Digitalmars-d-learn
mailing list