Is this a bug or a feature?
Don
nospam at nospam.com
Thu Jan 7 12:25:14 PST 2010
Ellery Newcomer wrote:
> On 01/07/2010 07:04 AM, Daniel Murphy wrote:
>> The following code compiles under dmd v2.037, no closing brace required.
>>
>> ---------------
>> import std.stdio;
>>
>> void main()
>> {
>> while(true)
>> writeln("Bug!");
>> ---------------
>>
>> Bug, or feature for the extremely lazy?
>
> in parse.c, Parser::parseStatement, around line 3533, there be
>
> case TOKlcurly:
> {
> nextToken();
> Statements *statements = new Statements();
> while (token.value != TOKrcurly && token.value != TOKeof)
> {
> statements->push(parseStatement(PSsemi | PScurlyscope));
> }
> .....
>
> don't know why the TOKeof is there, but that's what's causing the issue.
It's there to prevent malformed mixins from causing an infinite loop.
Seems like it should be replaced with an error message:
while (token != rcurly) {
if (token==TOKeof) { error("} expected"); break;}
statements->push()
}
More information about the Digitalmars-d
mailing list