[Issue 249] New: circular typedef and alias bugs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 10 18:44:44 PDT 2006


http://d.puremagic.com/issues/show_bug.cgi?id=249

           Summary: circular typedef and alias bugs
           Product: D
           Version: 0.162
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid, diagnostic, ice-on-invalid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: jpelcis at gmail.com


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.

-------------------------------

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.

-------------------------------

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.

-------------------------------

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.


-- 




More information about the Digitalmars-d-bugs mailing list