digitalmars.D.bugs - Interface Covariance Bug?
- John C (27/27) Mar 26 2006 This compiles, but produces some strange output on the cmd line (DMD 0.1...
- Walter Bright (2/2) Mar 27 2006 It's a forward reference problem. Try reversing the declarations of keys...
- John C (6/8) Mar 28 2006 Thanks - that fixed it.
- Stewart Gordon (14/23) Mar 28 2006 Correct.
- Stewart Gordon (15/24) Mar 28 2006 Looking at your code again, it appears to be a case of
- Walter Bright (5/7) Mar 28 2006 Generally, it isn't. But the internal semantic routines need to be
This compiles, but produces some strange output on the cmd line (DMD 0.150, Windows XP SP2): interface ICollection(T) { int length(); } interface IMap(TKey, TValue) { ICollection!(TKey) keys(); } class Map(TKey, TValue) : IMap!(TKey, TValue) { KeyCollection keys() { return new KeyCollection; } class KeyCollection : ICollection!(TKey) { int length() { return 5; } } } void main() { IMap!(int, int) map = new Map!(int, int); writefln(map.keys.length); } Output: KeyCollection 10227584 Why does it output "KeyCollection"? Is it some kind of runtime error? And why is map.keys.length not 5?
Mar 26 2006
It's a forward reference problem. Try reversing the declarations of keys() and KeyCollection.
Mar 27 2006
"Walter Bright" <newshound digitalmars.com> wrote in message news:e09vmu$2ubc$1 digitaldaemon.com...It's a forward reference problem. Try reversing the declarations of keys() and KeyCollection.Thanks - that fixed it. But surely it highlights a separate bug: forward referencing isn't supposed to be an issue in D, is it? John.
Mar 28 2006
John C wrote:"Walter Bright" <newshound digitalmars.com> wrote in message news:e09vmu$2ubc$1 digitaldaemon.com...Correct. You'll notice that many forward reference bugs have been filed both here and in DStress. But a forward reference bug that leads to bad code generation is a new one on me. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.It's a forward reference problem. Try reversing the declarations of keys() and KeyCollection.Thanks - that fixed it. But surely it highlights a separate bug: forward referencing isn't supposed to be an issue in D, is it?
Mar 28 2006
John C wrote:"Walter Bright" <newshound digitalmars.com> wrote in message news:e09vmu$2ubc$1 digitaldaemon.com...Looking at your code again, it appears to be a case of http://d.puremagic.com/bugzilla/show_bug.cgi?id=65 I've just noticed that my testcase contains a forward reference as well. Guess I'll have to try rewriting it without the forward reference and see what happens. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.It's a forward reference problem. Try reversing the declarations of keys() and KeyCollection.Thanks - that fixed it. But surely it highlights a separate bug: forward referencing isn't supposed to be an issue in D, is it?
Mar 28 2006
"John C" <johnch_atms hotmail.com> wrote in message news:e0avij$1bpj$1 digitaldaemon.com...But surely it highlights a separate bug: forward referencing isn't supposed to be an issue in D, is it?Generally, it isn't. But the internal semantic routines need to be reorganized/reimplemented to do this better, and I'm not up for that right now.
Mar 28 2006