From 7f11de666f0a2c7dee76aa6cd74c73fd0542c7c9 Mon Sep 17 00:00:00 2001 From: Fritz Zaucker Date: Tue, 6 Aug 2024 15:31:53 +0200 Subject: [PATCH] trm() warning (#233) * Make foreach function calls consistent * Warn for undefined arguments in trm() --- CHANGES | 2 ++ lib/CallBackery/Translate.pm | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 2e59a49..149f248 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ + - warn if trm() is called with undefined arguments + 0.49.6 2024-07-17 17:25:39 +0200 Tobias Oetiker - fix some more memory loops diff --git a/lib/CallBackery/Translate.pm b/lib/CallBackery/Translate.pm index 3f84aa9..31b7913 100644 --- a/lib/CallBackery/Translate.pm +++ b/lib/CallBackery/Translate.pm @@ -130,8 +130,14 @@ use overload }; sub trm ($str,@args) { - # make sure the arguments are stringified - return bless [$str,map { "$_" } @args]; + # make sure the arguments are stringified, warn if undefined + return bless [$str,map { + if (not defined $_) { + my ($package, $filename, $line) = caller; + warn "Undefined argument for str='$str' from $package line $line"; + } + "$_" + } @args]; } =head2 $str->TO_JSON