Skip to content

Commit

Permalink
Fix 'return-or-die' statements.
Browse files Browse the repository at this point in the history
Statements like this:

    return do_something() or die "something is wrong";

... are almost certainly mistakes. Since `or` has lower precedence
than `return`, it is equivalent to:

   ( return do_something() ) or die "something_is wrong";

Since `return` takes the value to caller, the `or` operator and the
order side of it never executes.
  • Loading branch information
gugod committed Jul 25, 2018
1 parent 0767294 commit ffd398a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Ukigumo/Server/API.pm
Expand Up @@ -9,7 +9,7 @@ use Ukigumo::Server::API::Dispatcher;

sub dispatch {
my $c = shift;
return Ukigumo::Server::API::Dispatcher->dispatch($c) or die "response is not generated";
return Ukigumo::Server::API::Dispatcher->dispatch($c) || die "response is not generated";
}

__PACKAGE__->load_plugins( 'Web::JSON' );
Expand Down
3 changes: 1 addition & 2 deletions lib/Ukigumo/Server/Web.pm
Expand Up @@ -11,8 +11,7 @@ use Ukigumo::Constants;
use Ukigumo::Server::Web::Dispatcher;
sub dispatch {
my $c = shift;
return Ukigumo::Server::Web::Dispatcher->dispatch($c)
or die "response is not generated";
return Ukigumo::Server::Web::Dispatcher->dispatch($c) || die "response is not generated";
}

# setup view class
Expand Down

0 comments on commit ffd398a

Please sign in to comment.