summaryrefslogtreecommitdiffstats
path: root/MDK
diff options
context:
space:
mode:
Diffstat (limited to 'MDK')
-rw-r--r--MDK/Common/Various.pm20
1 files changed, 20 insertions, 0 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;