develooper Front page | perl.perl5.porters | Postings from June 2008

Control flow ops, dead code, warnings

Thread Next
Yuval Kogman
June 28, 2008 09:30
Control flow ops, dead code, warnings
Message ID:
Under use warnings we get warnings for useless use in void context.

A somewhat related thing is expressions which involve two
conflicting types of control flow:

	my $value = return "Foo";

	redo && foo();


Maybe this is worth a warning, since that code can never be reached?

Some edge cases:

Obviously this shouldn't warn:

	return "foo";

Nor should:

	foo() && redo || bar

But this should:

	redo || bar

as should

	foo() && ( redo || bar() )

So, I think it boils down to an unconditional control op (return,
redo, goto, last, next) in an expression the 'first' of a logop

  Yuval Kogman <>  0xEBD27418

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About