Skip to content

Commit

Permalink
Warn for undefined arguments in trm()
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucker committed Aug 6, 2024
1 parent 006c810 commit eb422d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- warn if trm() is called with undefined arguments

0.49.6 2024-07-17 17:25:39 +0200 Tobias Oetiker <[email protected]>

- fix some more memory loops
Expand Down
10 changes: 8 additions & 2 deletions lib/CallBackery/Translate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb422d4

Please sign in to comment.