summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2001-12-20 12:47:14 +0000
committerPascal Rigaux <pixel@mandriva.com>2001-12-20 12:47:14 +0000
commitb3762a83bd205002bb53e7af0d1130f26c58719c (patch)
treec6fb88aabf40eaa7c120fe8c5b8b7cf6119fdce7
parentd9fcecf3ec79c33544662517e4135e1afa10f6af (diff)
downloadperl-MDK-Common-b3762a83bd205002bb53e7af0d1130f26c58719c.tar
perl-MDK-Common-b3762a83bd205002bb53e7af0d1130f26c58719c.tar.gz
perl-MDK-Common-b3762a83bd205002bb53e7af0d1130f26c58719c.tar.bz2
perl-MDK-Common-b3762a83bd205002bb53e7af0d1130f26c58719c.tar.xz
perl-MDK-Common-b3762a83bd205002bb53e7af0d1130f26c58719c.zip
add Various::noreturn()
-rw-r--r--MDK/Common/Various.pm20
-rw-r--r--perl-MDK-Common.spec5
2 files changed, 24 insertions, 1 deletions
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 <pixel@mandrakesoft.com> 1.0.2-8mdk
+- add Various::noreturn()
+
* Mon Sep 17 2001 Pixel <pixel@mandrakesoft.com> 1.0.2-7mdk
- (cp_af): fix typo