dstress alias_18.d (through 23)
    Brad Roberts 
    braddr at puremagic.com
       
    Sat Jan 27 00:55:53 PST 2007
    
    
  
http://dstress.kuehne.cn/nocompile/a/alias_19.d
   // $HeadURL: http://dstress.kuehne.cn/nocompile/a/alias_19.d $
   // $Date: 2005-12-03 23:19:07 +0100 (Sat, 03 Dec 2005) $
   // $Author: thomask $
   // @author@	zwang <nehzgnaw at gmail.com>
   // @date@	2005-05-01
   // @uri@	news:d5247u$28ch$2 at digitaldaemon.com
   // __DSTRESS_ELINE__ 13
   module dstress.nocompile.a.alias_19;
   alias static int mInt;
The uri references bugs/3859:
==== snip ====
   <code>
   void main(char[][] args){
           alias const char[] CS;
           CS cs = "string";
           switch(args[0]){
           case cs: break;
           }
   }
   </code>
   The code above is equivalent to
   <code>
   void main(char[][] args){
           const char[] cs = "string";
           switch(args[0]){
           case cs: break;
           }
   }
   </code>
==============
I just re-read the section on aliases in the docs and I don't see 
anything that suggests that 'alias <storage class> <type> <newtypename>' 
is illegal.  The closest it comes to being direct to this point is:
     It's sometimes convenient to use an alias for a type, such as a
     shorthand for typing out a long, complex type like a pointer to a
     function.
It's strange that only the 'alias const int mInt' version fails and all 
the other storage classes pass:
$ grep "alias " alias_*.d
alias_18.d:alias const int mInt;
alias_19.d:alias static int mInt;
alias_20.d:alias final int mInt;
alias_21.d:alias override int mInt;
alias_22.d:alias abstract int mInt;
alias_23.d:alias auto int mInt;
$ for x in 18 19 20 21 22 23; do echo == $x ==; dmd -c alias_$x.d; done
== 18 ==
alias_18.d(13): alias dstress.nocompile.a.alias_18.mInt cannot be const
== 19 ==
== 20 ==
== 21 ==
== 22 ==
== 23 ==
Any reason that all of these tests should be turned into 'should compile 
successfully' tests and a bug report filed for 18 since const aliases 
ought to work but doesn't?
Tested with dmd 1.00
Later,
Brad
    
    
More information about the Digitalmars-d-bugs
mailing list