changeset 1103:246bfd1f5ef5

[Issue 247] Cannot return from nested functions in contracts Deewiant <deewiant@gmail.com> 2006-07-09 news:bug-247-3@http.d.puremagic.com/issues/
author thomask
date Tue, 15 Aug 2006 09:45:30 +0000
parents 7187745681d9
children a9bd4f3bb932
files run/i/in_out_body_12_A.d run/i/in_out_body_12_B.d run/i/in_out_body_12_C.d
diffstat 3 files changed, 91 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/i/in_out_body_12_A.d	Tue Aug 15 09:45:30 2006 +0000
@@ -0,0 +1,30 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+// @author@	Deewiant <deewiant@gmail.com>
+// @date@	2006-07-09
+// @uri@	news:bug-247-3@http.d.puremagic.com/issues/
+// @desc@	[Issue 247] Cannot return from nested functions in contracts
+
+module dstress.run.i.in_out_body_12_A;
+
+void foo(int dummy)
+in {
+	static int checkParameters(int x) {
+		if(x < 0){
+			return checkParameters(-x);
+		}else{
+			return x % 2;
+		}
+	}
+
+	assert(checkParameters(dummy) == 1);
+} body {
+}
+
+int main(){
+	foo(5);
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/i/in_out_body_12_B.d	Tue Aug 15 09:45:30 2006 +0000
@@ -0,0 +1,30 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+// @author@	Deewiant <deewiant@gmail.com>
+// @date@	2006-07-09
+// @uri@	news:bug-247-3@http.d.puremagic.com/issues/
+// @desc@	[Issue 247] Cannot return from nested functions in contracts
+
+module dstress.run.i.in_out_body_12_B;
+
+void foo(int dummy)
+out{
+	static int checkParameters(int x) {
+		if(x < 0){
+			return checkParameters(-x);
+		}else{
+			return x % 2;
+		}
+	}
+
+	assert(checkParameters(dummy) == 1);
+} body {
+}
+
+int main(){
+	foo(5);
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/i/in_out_body_12_C.d	Tue Aug 15 09:45:30 2006 +0000
@@ -0,0 +1,31 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+// @author@	Deewiant <deewiant@gmail.com>
+// @date@	2006-07-09
+// @uri@	news:bug-247-3@http.d.puremagic.com/issues/
+// @desc@	[Issue 247] Cannot return from nested functions in contracts
+
+module dstress.run.i.in_out_body_12_C;
+
+int foo(int dummy)
+out(result){
+	static int checkParameters(int x) {
+		if(x < 0){
+			return checkParameters(-x);
+		}else{
+			return x % 2;
+		}
+	}
+
+	assert(checkParameters(result) == 1);
+} body {
+	return dummy+1;
+}
+
+int main(){
+	foo(4);
+
+	return 0;
+}