D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4145 - cross alias namespace can't be resolve
Summary: cross alias namespace can't be resolve
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-02 02:43 UTC by galaxylang
Modified: 2015-06-09 05:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description galaxylang 2010-05-02 02:43:55 UTC
//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 bearophile_hugs 2010-05-02 03:27:23 UTC
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 galaxylang 2010-05-02 04:57:02 UTC
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?