Thread overview | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
July 11, 2006 [Issue 249] New: circular typedef and alias bugs | ||||
---|---|---|---|---|
| ||||
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@digitalmars.com ReportedBy: jpelcis@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. -- |
July 11, 2006 Re: [Issue 249] New: circular typedef and alias bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | d-bugmail@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? |
July 11, 2006 Re: [Issue 249] New: circular typedef and alias bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote: > d-bugmail@puremagic.com wrote: >> test2.d(3): circular reference of typedef bar >> test2.d(3): circular reference of typedef bar >> >> snip >> >> test3.d(4): circular reference of typedef foo > > I'm not sure why the message is wrong. The code certainly is. I agree that the code is wrong. However, one of those is an alias and the other is a typedef. I suppose it could be debated which is which, but only one is a typedef. > It's still a reasonable error message - I agree it could be improved, but why is it a bug? I think that the error messages are good, even if they aren't perfect. My point is that those four pieces of code are essentially the same but all four produce different error messages. Could they all be made the same? |
July 11, 2006 Re: [Issue 249] New: circular typedef and alias bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to James Pelcis | James Pelcis wrote:
> I think that the error messages are good, even if they aren't perfect. My point is that those four pieces of code are essentially the same but all four produce different error messages. Could they all be made the same?
I like to keep error messages generated by different parts of the compiler slightly different - makes it easier to track them down.
|
July 11, 2006 Re: [Issue 249] New: circular typedef and alias bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Tue, 11 Jul 2006 15:53:11 +1000, Walter Bright <newshound@digitalmars.com> wrote: > James Pelcis wrote: >> I think that the error messages are good, even if they aren't perfect. My point is that those four pieces of code are essentially the same but all four produce different error messages. Could they all be made the same? > > I like to keep error messages generated by different parts of the compiler slightly different - makes it easier to track them down. Try using message IDs like most professional designers do. They are LOTS more easier to track, document and maintain. -- Derek Parnell Melbourne, Australia |
July 11, 2006 Re: message IDs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote: > Try using message IDs like most professional designers do. They are LOTS more easier to track, document and maintain. Yes, good idea. Compiler error IDs are also easy to look for in documentation (see VS + MSDN for example). -- |
July 12, 2006 Re: [Issue 249] New: circular typedef and alias bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote:
> On Tue, 11 Jul 2006 15:53:11 +1000, Walter Bright <newshound@digitalmars.com> wrote:
>
>> James Pelcis wrote:
>>> I think that the error messages are good, even if they aren't perfect. My point is that those four pieces of code are essentially the same but all four produce different error messages. Could they all be made the same?
>>
>> I like to keep error messages generated by different parts of the compiler slightly different - makes it easier to track them down.
>
> Try using message IDs like most professional designers do. They are LOTS more easier to track, document and maintain.
LOL. I use message IDs in the C++ compiler. I like using the text ones better. (And the issue is the same, if message X comes up, I like it generated in one place, which means each message ID must be used only once.)
|
July 12, 2006 Re: [Issue 249] New: circular typedef and alias bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> Derek Parnell wrote:
>> On Tue, 11 Jul 2006 15:53:11 +1000, Walter Bright <newshound@digitalmars.com> wrote:
>>
>>> James Pelcis wrote:
>>>> I think that the error messages are good, even if they aren't perfect. My point is that those four pieces of code are essentially the same but all four produce different error messages. Could they all be made the same?
>>>
>>> I like to keep error messages generated by different parts of the compiler slightly different - makes it easier to track them down.
>>
>> Try using message IDs like most professional designers do. They are LOTS more easier to track, document and maintain.
>
> LOL. I use message IDs in the C++ compiler. I like using the text ones better. (And the issue is the same, if message X comes up, I like it generated in one place, which means each message ID must be used only once.)
Perhaps a context ID would be useful? Could even encode it into the message ID--set the upper N bits as the message pointer and the lower N bits as the location. Still not quite as easy to track down as a search for an embedded string though, I'll admit.
Sean
|
July 12, 2006 Re: [Issue 249] New: circular typedef and alias bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> Derek Parnell wrote:
>> On Tue, 11 Jul 2006 15:53:11 +1000, Walter Bright <newshound@digitalmars.com> wrote:
>>
>>> James Pelcis wrote:
>>>> I think that the error messages are good, even if they aren't perfect. My point is that those four pieces of code are essentially the same but all four produce different error messages. Could they all be made the same?
>>>
>>> I like to keep error messages generated by different parts of the compiler slightly different - makes it easier to track them down.
>>
>> Try using message IDs like most professional designers do. They are LOTS more easier to track, document and maintain.
>
> LOL. I use message IDs in the C++ compiler. I like using the text ones better. (And the issue is the same, if message X comes up, I like it generated in one place, which means each message ID must be used only once.)
Once we have a 1.0 release, it might be good to have a grep the source to generate a list all of the possible error messages, then put them in a Wiki page.
|
July 12, 2006 Re: message IDs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Khropov | In article <e918in$lhk$1@digitaldaemon.com>, Andrei Khropov says... > >Derek Parnell wrote: > >> Try using message IDs like most professional designers do. They are LOTS more easier to track, document and maintain. > >Yes, good idea. > >Compiler error IDs are also easy to look for in documentation (see VS + MSDN >for example). Even if (or especially if) Walter wasn't the one doing the documenting, message IDs would be helpful. For example: http://www.prowiki.org/wiki4d/wiki.cgi?ErrorMessages/CompilerErrors jcc7 |
Copyright © 1999-2021 by the D Language Foundation