From 6e29ee686419f2c1ea57864b6693e971c73c0816 Mon Sep 17 00:00:00 2001 From: karupanerura Date: Mon, 23 Aug 2021 15:53:06 +0900 Subject: [PATCH 1/2] show warnings if enable/enable_if is called on non-void context --- lib/Plack/Builder.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Plack/Builder.pm b/lib/Plack/Builder.pm index 5156166d..72ee1890 100644 --- a/lib/Plack/Builder.pm +++ b/lib/Plack/Builder.pm @@ -109,9 +109,13 @@ sub builder(&) { $urlmap; }; local $_add = sub { + defined wantarray + or Carp::carp("WARNING: You used enable() on non-void context"); $self->add_middleware(@_); }; local $_add_if = sub { + defined wantarray + or Carp::carp("WARNING: You used enable_if() on non-void context"); $self->add_middleware_if(@_); }; From a23f1e52b7b70f0dc4029aa5fbe1f59688f9b0c1 Mon Sep 17 00:00:00 2001 From: karupanerura Date: Mon, 23 Aug 2021 21:15:46 +0900 Subject: [PATCH 2/2] fix incorrect condition for show the warnings --- lib/Plack/Builder.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Plack/Builder.pm b/lib/Plack/Builder.pm index 72ee1890..9b4d44ee 100644 --- a/lib/Plack/Builder.pm +++ b/lib/Plack/Builder.pm @@ -110,12 +110,12 @@ sub builder(&) { }; local $_add = sub { defined wantarray - or Carp::carp("WARNING: You used enable() on non-void context"); + and Carp::carp("WARNING: You used enable() in non-void context"); $self->add_middleware(@_); }; local $_add_if = sub { defined wantarray - or Carp::carp("WARNING: You used enable_if() on non-void context"); + and Carp::carp("WARNING: You used enable_if() in non-void context"); $self->add_middleware_if(@_); };