in reply to Strange behaviour when returning the value of "do {}" - possible perl bug?

I notice that bar will return 1 if you introduce a scalar context explicitly.

sub bar{ if (1){ return scalar do { #do block will return 1 if (1){ 1; } 1; }; } }

I notice also that B::Deparse turns 'if(1)' into do, so you also get '1' if you give the optimizer more to chew on:

sub bar{ my $truth = 'beauty'; if ($truth){ return do { #do block will return 1 if ($truth) { 1; } 1; }; } }

My guess is that the scalar context is getting lost in all those nested do blocks, but even so, I can't see why that would be a problem. It looks like a bug to me.