From b3762a83bd205002bb53e7af0d1130f26c58719c Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 20 Dec 2001 12:47:14 +0000 Subject: add Various::noreturn() --- MDK/Common/Various.pm | 20 ++++++++++++++++++++ perl-MDK-Common.spec | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/MDK/Common/Various.pm b/MDK/Common/Various.pm index a8de5fb..0d8f008 100644 --- a/MDK/Common/Various.pm +++ b/MDK/Common/Various.pm @@ -67,6 +67,18 @@ gives oops main::g() called from /tmp/t.pl:2 main::f() called from /tmp/t.pl:4 + +=item noreturn() + +use this to ensure nobody uses the return value of the function. eg: + + sub g { print "g called\n"; noreturn } + sub f { print "g returns ", g() } + f(); + +gives + + test.pl:3: main::f() expects a value from main::g(), but main::g() doesn't return any value =back @@ -107,5 +119,13 @@ sub backtrace { $s; } +sub noreturn { + if (defined wantarray) { + my ($package, $file, $line, $func) = caller(1); + my (undef, undef, undef, $func2) = caller(2); + die "$file:$line: $func2() expects a value from $func(), but $func() doesn't return any value\n"; + } +} + 1; diff --git a/perl-MDK-Common.spec b/perl-MDK-Common.spec index 477b509..41b44f8 100644 --- a/perl-MDK-Common.spec +++ b/perl-MDK-Common.spec @@ -2,7 +2,7 @@ # do not change the version here, change in MDK/Common.pm.pl %define version THEVERSION -%define release 7mdk +%define release 8mdk %define perl_sitelib %(eval "`perl -V:installsitelib`"; echo $installsitelib) Summary: Various simple functions @@ -50,6 +50,9 @@ rm -rf $RPM_BUILD_ROOT # MODIFY IN THE CVS: cvs.mandrakesoft.com:/cooker soft/perl-MDK-Common %changelog +* Thu Dec 20 2001 Pixel 1.0.2-8mdk +- add Various::noreturn() + * Mon Sep 17 2001 Pixel 1.0.2-7mdk - (cp_af): fix typo -- cgit v1.2.1