Re: Issue with 2.071: Regression or valid error?
On Wednesday, 6 April 2016 at 15:10:45 UTC, 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 {}; compile with rdmd a b Not so up to date on D's OOP stuff, but don't you want create() to be protected, not private. You can typically access a private method through a base class, which is what you are doing with cat.create().
Re: Issue with 2.071: Regression or valid error?
On Wednesday, 6 April 2016 at 19:01:58 UTC, Craig Dillabaugh wrote: On Wednesday, 6 April 2016 at 15:10:45 UTC, Andre wrote: clip Not so up to date on D's OOP stuff, but don't you want create() to be protected, not private. You can typically access a private method through a base class, which is what you are doing with cat.create(). You CAN'T typically access a private ...
Re: Issue with 2.071: Regression or valid error?
This should not compile. Cat cant access create because it is private. Ok it can access it but only if you move cat into same module as animal Dne 6. 4. 2016 17:16 napsal uživatel "Andre via Digitalmars-d-learn" < digitalmars-d-learn@puremagic.com>: > 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 {}; > > compile with > >> rdmd a b >>> >>
Re: Issue with 2.071: Regression or valid error?
On Wednesday, 6 April 2016 at 19:22:44 UTC, Daniel Kozak wrote: This should not compile. Cat cant access create because it is private. Ok it can access it but only if you move cat into same module as animal Dne 6. 4. 2016 17:16 napsal uživatel "Andre via Digitalmars-d-learn" < digitalmars-d-learn@puremagic.com>: Thanks for the answers. Kind regards André
Re: Issue with 2.071: Regression or valid error?
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
Re: Issue with 2.071: Regression or valid error?
On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote: On 4/6/16 11:10 AM, Andre wrote: [...] Just FYI, you don't need a semicolon there. [...] 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 Why this is a bug? private methods are not virtual, are they? --Ilya
Re: Issue with 2.071: Regression or valid error?
On Friday, 8 April 2016 at 06:08:38 UTC, 9il wrote: On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote: On 4/6/16 11:10 AM, Andre wrote: [...] Just FYI, you don't need a semicolon there. [...] 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 Why this is a bug? private methods are not virtual, are they? --Ilya No they are not virtual, so this is not a bug.
Re: Issue with 2.071: Regression or valid error?
On Friday, 8 April 2016 at 08:26:11 UTC, Daniel Kozak wrote: On Friday, 8 April 2016 at 06:08:38 UTC, 9il wrote: On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote: 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 Why this is a bug? private methods are not virtual, are they? --Ilya No they are not virtual, so this is not a bug. I disagree, virtuality has nothing to do with this. After all, moving Cat to the same module as Animal, or making create() public final will make the code compile. Private symbols can (only) be accessed from the module where they are defined, so anything in the animal module should be able to call create() on a Cat just fine.
Re: Issue with 2.071: Regression or valid error?
On 4/8/16 2:08 AM, 9il wrote: On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote: On 4/6/16 11:10 AM, Andre wrote: [...] Just FYI, you don't need a semicolon there. [...] 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. Why this is a bug? private methods are not virtual, are they? --Ilya A Cat is an Animal. The compiler knows this. The 'a' module has access to Animal private methods. This isn't a virtual call, but a call to a base class member. Those are allowed. How can you think this is not a bug? Would you think it was a bug if create was a final function instead of private? This is exactly the same thing. -Steve
Re: Issue with 2.071: Regression or valid error?
On 4/7/16 11:55 AM, Steven Schveighoffer wrote: Please file a bug report, not sure why this happened. I filed it for you: https://issues.dlang.org/show_bug.cgi?id=15897 -Steve
Re: Issue with 2.071: Regression or valid error?
Dne 8.4.2016 v 14:56 Steven Schveighoffer via Digitalmars-d-learn napsal(a): On 4/8/16 2:08 AM, 9il wrote: On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote: On 4/6/16 11:10 AM, Andre wrote: [...] Just FYI, you don't need a semicolon there. [...] 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. Why this is a bug? private methods are not virtual, are they? --Ilya A Cat is an Animal. The compiler knows this. The 'a' module has access to Animal private methods. This isn't a virtual call, but a call to a base class member. Those are allowed. How can you think this is not a bug? Would you think it was a bug if create was a final function instead of private? This is exactly the same thing. -Steve Yes ou are right, I see it now :), thanks.