Detect the bug in the following code

Idan Arye via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 15 08:05:39 PDT 2015


On Wednesday, 15 April 2015 at 14:46:56 UTC, Adam D. Ruppe wrote:
> On Wednesday, 15 April 2015 at 14:44:48 UTC, Idan Arye wrote:
>>        register = true;
>
> Easy, you assigned to the wrong variable, that'd quickly be 
> obvious at runtime too with a stack overflow.
>
> I think it sucks that true and false will implicitly convert to 
> int though, that bites people somewhat often. I wonder how much 
> annoyance it would be to remove that implicit conversion.

Yea, in this example it's quite obvious, but I've just before 
posting it I realized I did this mistake in a much larger 
project, and it was harder to detect(I was getting a double 
registration error in another module rather than a stack 
overflow).

At any rate, I don't think the problem is the implicit conversion 
as much as it is the property syntax...


More information about the Digitalmars-d mailing list