view run/s/scope_17_D.d @ 1455:a4dc53fd9f2e

[Issue 1087] Scope classes not destroyed in labeled statements in switches Jarrett Billingsley <jarrett.billingsley@gmail.com> 2007-03-30 http://d.puremagic.com/issues/show_bug.cgi?id=1087
author thomask
date Thu, 05 Apr 2007 10:18:36 +0000
parents
children
line wrap: on
line source

// $HeadURL$
// $Date$
// $Author$

// @author@	Jarrett Billingsley <jarrett.billingsley@gmail.com>
// @date@	2007-03-30
// @uri@	http://d.puremagic.com/issues/show_bug.cgi?id=1087
// @desc@	[Issue 1087] Scope classes not destroyed in labeled statements in switches

module dstress.run.s.scope_17_D;

int i[];

scope class A{
	~this(){
		i ~= 3;
	}
}

int main(){
	i ~= 0;

	switch(i.length)
	{
		L2:
			scope a = new A();
			scope(exit) i ~= 2;
			i ~= 1;
			break;
		case 1:
			goto L2;
	}
	i ~= 4;
	
	if([0, 1, 2, 3, 4] != i){
		assert(0);
	}

	return 0;
}