[Issue 249] New: circular typedef and alias bugs

Walter Bright newshound at digitalmars.com
Mon Jul 10 19:27:11 PDT 2006


d-bugmail at puremagic.com wrote:
> Here are a few closely related bugs with circular typedefs and aliases.  The
> most important one is the first (it crashes the compiler), but each version has
> the same problem but a different error message.
> 
> -------------------------------
> 
> module test1;
> 
> typedef foo bar;
> typedef bar foo;
> 
> void main () {
>         foo blah;
> }
> 
> C:\programs>dmd test1.d -v
> parse     test1
> semantic  test1
> semantic2 test1
> semantic3 test1
> Stack overflow
> 
> 
> Without an error message, this can be almost impossible to track down.

Yes, that is a bug.

> -------------------------------
> 
> module test2;
> 
> typedef foo bar;
> alias bar foo;
> 
> void main () {
>         foo blah;
> }
> 
> C:\programs>dmd test2.d
> test2.d(3): circular reference of typedef bar
> test2.d(3): circular reference of typedef bar
> 
> 
> Interesting way to phrase the error message.  It also appears twice, but only
> shows one of the line numbers.

Generally, the compiler tries to invent a fix to continue on from a 
syntax error, but often those fixes just result in more error messages. 
Not great, but not really a bug.

> -------------------------------
> 
> module test3;
> 
> alias foo bar;
> typedef bar foo;
> 
> void main () {
>         foo blah;
> }
> 
> C:\programs>dmd test3.d
> test3.d(4): circular reference of typedef foo
> 
> 
> This error message is similar to the last one, but it only shows up once this
> time.  Is it really still a typedef though, or is it an alias?  Either way, one
> is wrong.

I'm not sure why the message is wrong. The code certainly is.

> 
> -------------------------------
> 
> module test4;
> 
> alias foo bar;
> alias bar foo;
> 
> void main () {
>         foo blah;
> }
> 
> C:\programs>dmd test4.d
> test4.d(4): alias test4.foo recursive alias declaration
> 
> 
> I think the "circular" from the other error messages is better than
> "recursive."  Also, it still only has one of the line numbers and for some
> reason is the only one that keeps the module name.

It's still a reasonable error message - I agree it could be improved, 
but why is it a bug?



More information about the Digitalmars-d-bugs mailing list