www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Curiously Cyclic Template Pattern causes segfault?

reply "Patrick Jeeves" <pdj9 pitt.edu> writes:
When I tried to test out the following code the compiler 
segfaulted:


interface BarBase
{
	void do_a_thing();
}

interface Bar(T) : BarBase
{
	static if(hasMember!(T, "rotation") && is(typeof(T.rotation) == 
double))
	{
		 property
		double rotation();
		
		final void do_a_thing()
		{
			//do a thing with rotation;
		}
	}
	else
	{
		final void do_a_thing()
		{
			//do a thing without rotation;
		}
	}
}

class Foo1 : Bar!Foo1
{
}

class Foo2 : Bar!Foo2
{
	 property
	double rotation() { return 1.0; };
}

Is there some rule against doing this or is it a glitch?
Nov 05 2014
parent reply Justin Whear <justin economicmodeling.com> writes:
On Wed, 05 Nov 2014 20:48:06 +0000, Patrick Jeeves wrote:

 When I tried to test out the following code the compiler segfaulted:
 
 Is there some rule against doing this or is it a glitch?
Please file a bug report on issues.dlang.org --any compiler crash is a bug regardless of whether the source is valid D code or not.
Nov 05 2014
parent "bearophile" <bearophileHUGS lycos.com> writes:
Justin Whear:

 --any compiler crash is a bug
 regardless of whether the source is valid D code or not.
I suspect that in some cases those compiler crashes are a way for the compiler to tell the programmer that the code was too much hairy and too much hard to understand ;-) Bye, bearophile
Nov 05 2014