Ok, this is a *very* hard problem to track down, as it is subtly dependent on the order of instantiations. The problem is that std.array.Appender has 3 put() member templates. We are only concerned with the first and last one. If we pass an argument of type:

   char[]

to put(), it winds up tripping the recursive constraint detection in template.c, causing the constraint to fail, and the put() template is not instantiated.

The recursive part is not actually in the template constraint, it is in the body of put(). So it only happens when semantic3() is called on the template instantiation while inside the constraint of another instantiation. The reason for the erratic nature of the bug happening is that if semantic3() has already been called for the instantiation, it isn't called again. Also, sometimes the call to semantic3() is deferred to another module, or is deferred for other reasons, and so the error doesn't happen.

I thought about fixing the template so it wasn't recursive, but then thought this mysterious error would crop up elsewhere and confound the next person. So that was out. I still thought it best to eagerly attempt to do semantic3(). But bugzilla 4072 is the reason for the recursive protection code in the first place.

Finally, I decided upon a rather hackish solution - let the recursion detection code run a couple times before it trips. It doesn't seem right, but I can't think of anything better at the moment.
_______________________________________________
dmd-beta mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-beta

Reply via email to