http://d.puremagic.com/issues/show_bug.cgi?id=5709
Summary: template instantiation fails with extra non-mutable class parameter Product: D Version: unspecified Platform: All OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: jmdavisp...@gmx.com --- Comment #0 from Jonathan M Davis <jmdavisp...@gmx.com> 2011-03-05 18:35:26 PST --- This program fails to compile import std.traits; class C { } void func1(S)(in S str, immutable C a = null) if(isSomeString!S) { func2(str, a); } void func2(S)(in S str, immutable C a = null) if(isSomeString!S) { } void main() { func1("hello world"); func2("hello world"); } giving this error: q.d(10): Error: template q.func2(S) if (isSomeString!(S)) does not match any function template declaration q.d(10): Error: template q.func2(S) if (isSomeString!(S)) cannot deduce template function from argument types !()(const(immutable(char)[]),immutable(C)) q.d(20): Error: template instance q.func1!(string) error instantiating Removing the template constraints has no effect. Thus far, anything that I change immutable C a to anything other than a const C, _does_ compile, but it fails to compile as long as it's const or immutable. The fact that it's a default parameter seems to have no effect. If pass it a new C() instead of null, that has no effect. If I change the func2 call in func1 to func2!S, then it compiles just fine. But for some reason, when the second class parameter is there and it's not mutable, the template instantiation fails to determine the correct type of S for the inner instantiation, and you're forced to tell it. So, this bug is just plain weird, and it _can_ be gotten around, but it's _definitely_ a bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------