www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4145] New: cross alias namespace can't be resolve

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4145

           Summary: cross alias  namespace can't be resolve
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: galaxylang gmail.com


--- Comment #0 from galaxylang <galaxylang gmail.com> 2010-05-02 02:43:55 PDT
---
//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)
{
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4145


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc


--- Comment #1 from bearophile_hugs eml.cc 2010-05-02 03:27:23 PDT ---
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)'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4145



--- Comment #2 from galaxylang <galaxylang gmail.com> 2010-05-02 04:57:02 PDT
---
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?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02 2010