Issue with 2.071: Regression or valid error?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 7 08:55:16 PDT 2016


On 4/6/16 11:10 AM, Andre wrote:
> Hi,
>
> With 2.071 following coding does not compile anymore and somehow I feel
> it should compile.
> The issue is with line "cat.create();".
> Cat is a sub type of Animal. Animal "owns" method create and I want to
> call the method
> create within the class Animal for cat.
>
> Is the error message "no property create for type 'b.cat'" valid or not?
>
> Kind regards
> André
>
> module a;
> import b;
>
> class Animal
> {
>      private void create() {}
>
>      void foo(Cat cat)
>      {
>          cat.create(); // >> no property create for type 'b.cat'
>      }
> }
>
> void main() {}
>
> --------------
>
> module b;
> import a;
>
> class Cat: Animal {};

Just FYI, you don't need a semicolon there.

>
> compile with
>>> rdmd a b

Wow, totally agree with you. Compiler shouldn't make you jump through 
this hoop:

void foo(Cat cat)
{
    Animal a = cat;
    a.create();
}

Please file a bug report, not sure why this happened.

-Steve


More information about the Digitalmars-d-learn mailing list