Bug 4145 – cross alias namespace can't be resolve

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-05-02T02:43:00Z
Last change time
2015-06-09T05:14:56Z
Assigned to
nobody
Creator
galaxylang

Comments

Comment #0 by galaxylang — 2010-05-02T02:43:55Z
//restrictly speakin, it's a language feature,not a bug //The cross reference namespace can't be resolve in two level way? //D can support it? class Token { } class KeyWord(string V):Token { } class Seq(T...) { } class Any(T...) { } class And(T...) { } class List(T) { } alias Token TkID; alias KeyWord!("+") TkAdd; alias KeyWord!("-") TkSub; alias KeyWord!("(") TkLeftBracket; alias KeyWord!(")") TkRightBracket; alias Any!(TkAdd,TkSub) TkAddSub; alias TkID Invoker; alias TkID ExpConst; //here,report error ,ExpUnary is alias follow alias List!ExpUnary ExpList; alias Seq!(Invoker,TkLeftBracket,ExpList,TkRightBracket) ExpFunc; alias Any!(TkID,ExpConst,ExpFunc) ExpUnary; alias Seq!(ExpUnary,TkAddSub,ExpUnary) ExpAddSub; void main(string[] args) { }
Comment #1 by bearophile_hugs — 2010-05-02T03:27:23Z
This code can contain more than one problem. This is a reduced test case that shows one of the problems: class A(T) {} class B(T) {} alias B!Foo Bar; alias A!(int) Foo; void main() {} dmd 2.043 shows: test.d(3): Error: forward reference to 'A!(int)'
Comment #2 by galaxylang — 2010-05-02T04:57:02Z
So a alternative way to solve this problem is re-typedef the it class A(T) {} class B(T) {} alias B!Foo Bar; typedef A!(int) Foo; void main() {} but this will cause a new problem,see below class A { static A create(); } typedef A B; unittest { B b=B.create();//error: A can't convert to B } should A create() change to B create when typedef used?