www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - alias example is incorrect on website

reply K.Wilson <k.wilson nospam.nowhere.com> writes:
Hello all,

The example for alias declarations is incorrect here:

http://digitalmars.com/d/1.0/declaration.html

struct S { static int i; }
S s;

alias s.i a;	// illegal, s.i is an expression
alias S.i b;	// ok
b = 4;       // sets S.i to 4

The 'alias s.i a;' statement is not flagged as illegal by the dmd compiler (or
ldc or gdc), so I assume it is legal. The compilers seem to be assigning an
'int' type to 'a', as expected.

Maybe I am misreading something.

Thanks,
K.Wilson
Jan 04 2009
parent Jason House <jason.james.house gmail.com> writes:
K.Wilson Wrote:

 Hello all,
 
 The example for alias declarations is incorrect here:
 
 http://digitalmars.com/d/1.0/declaration.html
 
 struct S { static int i; }
 S s;
 
 alias s.i a;	// illegal, s.i is an expression
 alias S.i b;	// ok
 b = 4;       // sets S.i to 4
 
 The 'alias s.i a;' statement is not flagged as illegal by the dmd compiler (or
ldc or gdc), so I assume it is legal. The compilers seem to be assigning an
'int' type to 'a', as expected.
 
 Maybe I am misreading something.
 
 Thanks,
 K.Wilson
 
 
Looks like a bug in the (shared) dmd front end. File a bug report
Jan 05 2009