changeset 1294:8a9ce6778db2

[Issue 686] [Regression] opCast of a struct or union is called in nonsensical circumstances Stewart Gordon <smjg@iname.com> 2006-12-13 http://d.puremagic.com/issues/show_bug.cgi?id=686
author thomask
date Sat, 30 Dec 2006 15:39:26 +0000
parents 744c4ec3e3e3
children b5658302a26b
files run/o/opCast_04_A.d run/o/opCast_04_B.d
diffstat 2 files changed, 74 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/o/opCast_04_A.d	Sat Dec 30 15:39:26 2006 +0000
@@ -0,0 +1,39 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+// @author@	Stewart Gordon <smjg@iname.com>
+// @date@	2006-12-13
+// @uri@	http://d.puremagic.com/issues/show_bug.cgi?id=686
+// @desc@	[Issue 686] [Regression] opCast of a struct or union is called in nonsensical circumstances
+
+module dstress.run.o.opCast_04_A;
+
+struct Dog {
+	int i = 1;
+
+	Cat opCast() {
+		return Cat.init;
+	}
+}
+
+struct Cat {
+	int i  = 2;
+
+	Dog foo() {
+		return Dog.init;
+	}
+
+	void bar() {
+		Dog d = foo();
+		if(d.i != 1){
+			assert(0);
+		}
+	}
+}
+
+int main(){
+	Cat c;
+	c.bar();
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/o/opCast_04_B.d	Sat Dec 30 15:39:26 2006 +0000
@@ -0,0 +1,35 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+// @author@	Stewart Gordon <smjg@iname.com>
+// @date@	2006-12-13
+// @uri@	http://d.puremagic.com/issues/show_bug.cgi?id=686
+// @desc@	[Issue 686] [Regression] opCast of a struct or union is called in nonsensical circumstances
+
+module dstress.run.o.opCast_04_B;
+
+struct Dog {
+	int i = 1;
+}
+
+struct Cat {
+	int i  = 2;
+
+	Dog foo() {
+		return Dog.init;
+	}
+
+	void bar() {
+		Dog d = foo();
+		if(d.i != 1){
+			assert(0);
+		}
+	}
+}
+
+int main(){
+	Cat c;
+	c.bar();
+	return 0;
+}