View mode: basic / threaded / horizontal-split · Log in · Help
December 06, 2005
Bizarre Exception/Throwing/Templates/Something else Bug Pt II (Ready for Walter)
OK, so I've spent all evening whiddling this one down, and I've distilled it
to the attached, the only dependency being phobos.

The output should be:
before except
caught

However, it is:
before except
Error: uups

If line 51 is commented out, it works.  If any of the method bodies in the
parameterized classes is deleted, it also works.

Although I've managed to get the test case this small, I'm not smart enough
to generalize it.  Anybody see the pattern?  It doesn't seem obvious to me.

~John Demme
December 10, 2005
Re: Bizarre Exception/Throwing/Templates/Something else Bug Pt II (Ready for Walter)
John Demme schrieb am 2005-12-06:
> OK, so I've spent all evening whiddling this one down, and I've distilled it
> to the attached, the only dependency being phobos.
>
> The output should be:
> before except
> caught
>
> However, it is:
> before except
> Error: uups
>
> If line 51 is commented out, it works.  If any of the method bodies in the
> parameterized classes is deleted, it also works.
>
> Although I've managed to get the test case this small, I'm not smart enough
> to generalize it.  Anybody see the pattern?  It doesn't seem obvious to me.
>
> ~John Demme

> import std.cstream;
> import std.array;
>
> abstract class Container(V) {
>   	public abstract int opApply(int delegate(inout V) dg);
> }
>
> public abstract class MutableList(V): Container!(V) {
> 	public abstract MutableList insertBefore(int i, V item);
>
> 	public abstract MutableList append(V item);
> 	public abstract MutableList append(Container!(V) items);
>
> 	public abstract MutableList prepend(Container!(V) items);
> }
>
> class AbstractMutableList(V): MutableList!(V) {
> 	public MutableList!(V) append(Container!(V) items) {
> 	  	foreach(V item; items) {
> 			MutableList!(V).append(item);
> 	  	}
> 		return this;
>   	}
>
> 	public MutableList!(V) prepend(Container!(V) items) {
> 	  	int i=0;
> 	  	foreach(V item; items) {
> 	    		insertBefore(i++, item);
> 	  	}
> 	  	return this;
> 	}
>
> }
>
> public class ArrayList(V): AbstractMutableList!(V) {
>   private V[] myArray;
>
>   this(Container!(V) items) {
>     try {
>       foreach(V item; items) {
> 	myArray ~= item;
>       }
>     } catch (ArrayBoundsError e) {
>       throw new Exception(e.toString);
>     } 
>   }
> }
>
> class CommandLine {
>   // comment/uncomment the following line
>   ArrayList!(int) paramList;
> }
>
> int main( char[][] args ) {
>   return 0;
> }
>
> unittest {
>   void testBoolParam() {
>     try {
>       dout.writefln("before except");
>       throw new Exception( "uups" );
>     } catch (Object o) {
>       dout.writefln("caught");
>     }
>   }
>
>   testBoolParam();
> }

Am I missing something or is there any non-abstract version of
MutableList.insertBefore?

Thomas
December 16, 2005
Re: Bizarre Exception/Throwing/Templates/Something else Bug Pt II (Ready for Walter)
John Demme schrieb am 2005-12-06:
> --nextPart8053964.NWeQqG34Qg
> Content-Type: text/plain; charset=iso-8859-1
> Content-Transfer-Encoding: 8Bit
>
> OK, so I've spent all evening whiddling this one down, and I've distilled it
> to the attached, the only dependency being phobos.
>
> The output should be:
> before except
> caught
>
> However, it is:
> before except
> Error: uups
>
> If line 51 is commented out, it works.  If any of the method bodies in the
> parameterized classes is deleted, it also works.
>
> Although I've managed to get the test case this small, I'm not smart enough
> to generalize it.  Anybody see the pattern?  It doesn't seem obvious to me.
>
> ~John Demme

Added to DStress as
http://dstress.kuehne.cn/run/o/odd_bug_04_A.d
http://dstress.kuehne.cn/run/o/odd_bug_04_B.d
http://dstress.kuehne.cn/run/o/odd_bug_04_C.d
http://dstress.kuehne.cn/run/o/odd_bug_04_D.d
http://dstress.kuehne.cn/run/o/odd_bug_04_E.d
http://dstress.kuehne.cn/run/o/odd_bug_04_F.d

Thomas
Top | Discussion index | About this forum | D home