[dmd-internals] runnable/sdtor.d
Brad Roberts
braddr at puremagic.com
Thu Jun 2 22:16:31 PDT 2011
On 6/2/2011 11:15 AM, Brad Roberts wrote:
>
>
> On Jun 2, 2011, at 11:05 AM, Walter Bright <walter at digitalmars.com> wrote:
>
>>
>>
>> On 6/2/2011 9:04 AM, Brad Roberts wrote:
>>> With the changes to switch to require a default handler, there's some fall-out in runnable/sdtor.d.
>>>
>>> line 1271:
>>> if (0) switch(1) A51 a;
>>>
>>> runnable/sdtor.d(1271): Error: non-final switch statement must have a default
>>
>> I just made it a final switch
>
> Final shouldn't change the error. The case of 1 isn't handled.
>
>>> + A51_a = 0; A51 a; with(a) A51 b; assert(A51_a == 1); // should be 2, right?
>>>
>>
>> No, 1. Because 'a' isn't destructed until the end of the scope, which hasn't happened by the the time the assert is called.
>
> Good catch. Each of those should probably be pushed into an enclosing block.
The new contents of test51:
+ A51_a = 0; { while(0) A51 a; } assert(A51_a == 0);
+ A51_a = 0; { if(0) A51 a; } assert(A51_a == 0);
+ A51_a = 0; { if(1){} else A51 a; } assert(A51_a == 0);
+ A51_a = 0; { for(;0;) A51 a; } assert(A51_a == 0);
+ A51_a = 0; { if (1) { A51 a; } } assert(A51_a == 1);
+ A51_a = 0; { if (1) A51 a; } assert(A51_a == 1);
+ A51_a = 0; { if(0) {} else A51 a; } assert(A51_a == 1);
+ A51_a = 0; { if (0) for(A51 a;;) {} } assert(A51_a == 0);
+ A51_a = 0; { if (0) for(;;) A51 a; } assert(A51_a == 0);
+ A51_a = 0; { do A51 a; while(0); } assert(A51_a == 1);
+ A51_a = 0; { if (0) while(1) A51 a; } assert(A51_a == 0);
+ A51_a = 0; { try A51 a; catch(Error e) {} } assert(A51_a == 1);
+ A51_a = 0; { if (0) final switch(1) A51 a; } assert(A51_a == 0); // should fail to build
+ A51_a = 0; { if (0) switch(1) { A51 a; default: } } assert(A51_a == 0);
+ A51_a = 0; { if (0) switch(1) { default: A51 a; } } assert(A51_a == 0);
+ A51_a = 0; { if (1) switch(1) { A51 a; default: } } assert(A51_a == 1); // should be 0, right?
+ A51_a = 0; { if (1) switch(1) { default: A51 a; } } assert(A51_a == 1);
+ A51_a = 0; { final switch(0) A51 a; } assert(A51_a == 0);
+ A51_a = 0; { A51 a; with(a) A51 b; } assert(A51_a == 2);
Any reason not to commit this followed by opening two bugs for the two commented lines?
More information about the dmd-internals
mailing list