digitalmars.D.learn - Template specification conflict
- simendsjo (11/11) Aug 02 2011 The following program gives me
- Dmitry Olshansky (8/19) Aug 02 2011 struct S {
- simendsjo (8/29) Aug 02 2011 With the empty templated this, I get other errors though:
- Dmitry Olshansky (6/38) Aug 02 2011 Same logic here once you have template constructor, all others need to
- simendsjo (4/43) Aug 02 2011 So my first example is a bug, and the second is a wrong error message?
- Dmitry Olshansky (9/53) Aug 02 2011 I think there is only one bug: template constructor (and functions IIRC)...
- simendsjo (22/74) Aug 02 2011 While changing ctors to templates, I came across another issue (bug?)
- Dmitry Olshansky (4/80) Aug 02 2011 Most definitely a bug, you seem to hit a lot of 'em recently :)
- simendsjo (3/55) Aug 02 2011 Yup, old bug.
- Jonathan M Davis (2/53) Aug 02 2011 http://d.puremagic.com/issues/show_bug.cgi?id=2972
The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}
Aug 02 2011
On 02.08.2011 15:06, simendsjo wrote:The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}struct S { this()(uint i) {} this(C)(C c) if(isSomeChar!C) {} } should do it, though it (and workaround) looks like a bug to me. -- Dmitry Olshansky
Aug 02 2011
On 02.08.2011 13:55, Dmitry Olshansky wrote:On 02.08.2011 15:06, simendsjo wrote:With the empty templated this, I get other errors though: "t.d(5): Error: constructor t.S.this conflicts with template t.S.__ctor() at t.d(4)" struct S { this()(int a) {} // 4 this(int a, int b) {} // 5 }The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}struct S { this()(uint i) {} this(C)(C c) if(isSomeChar!C) {} } should do it, though it (and workaround) looks like a bug to me.
Aug 02 2011
On 02.08.2011 16:06, simendsjo wrote:On 02.08.2011 13:55, Dmitry Olshansky wrote:Same logic here once you have template constructor, all others need to be template, empty spec is a trick to get anything to be a template. And in this example you really do not need empty spec () in 4. -- Dmitry OlshanskyOn 02.08.2011 15:06, simendsjo wrote:With the empty templated this, I get other errors though: "t.d(5): Error: constructor t.S.this conflicts with template t.S.__ctor() at t.d(4)" struct S { this()(int a) {} // 4 this(int a, int b) {} // 5 }The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}struct S { this()(uint i) {} this(C)(C c) if(isSomeChar!C) {} } should do it, though it (and workaround) looks like a bug to me.
Aug 02 2011
On 02.08.2011 14:13, Dmitry Olshansky wrote:On 02.08.2011 16:06, simendsjo wrote:So my first example is a bug, and the second is a wrong error message? Wondering what I should post in a potential bug report, and if it's one or two bugs.On 02.08.2011 13:55, Dmitry Olshansky wrote:Same logic here once you have template constructor, all others need to be template, empty spec is a trick to get anything to be a template. And in this example you really do not need empty spec () in 4.On 02.08.2011 15:06, simendsjo wrote:With the empty templated this, I get other errors though: "t.d(5): Error: constructor t.S.this conflicts with template t.S.__ctor() at t.d(4)" struct S { this()(int a) {} // 4 this(int a, int b) {} // 5 }The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}struct S { this()(uint i) {} this(C)(C c) if(isSomeChar!C) {} } should do it, though it (and workaround) looks like a bug to me.
Aug 02 2011
On 02.08.2011 16:18, simendsjo wrote:On 02.08.2011 14:13, Dmitry Olshansky wrote:I think there is only one bug: template constructor (and functions IIRC) can't be overloaded with non-template. Both your examples show this bug, since this()(int a){} and this(C)(C c) if(isSomeChar!C) {} are template constructors, while others are not. I think the bug was there for quite some time and likely to be filed already, so check Bugzilla first. -- Dmitry OlshanskyOn 02.08.2011 16:06, simendsjo wrote:So my first example is a bug, and the second is a wrong error message? Wondering what I should post in a potential bug report, and if it's one or two bugs.On 02.08.2011 13:55, Dmitry Olshansky wrote:Same logic here once you have template constructor, all others need to be template, empty spec is a trick to get anything to be a template. And in this example you really do not need empty spec () in 4.On 02.08.2011 15:06, simendsjo wrote:With the empty templated this, I get other errors though: "t.d(5): Error: constructor t.S.this conflicts with template t.S.__ctor() at t.d(4)" struct S { this()(int a) {} // 4 this(int a, int b) {} // 5 }The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}struct S { this()(uint i) {} this(C)(C c) if(isSomeChar!C) {} } should do it, though it (and workaround) looks like a bug to me.
Aug 02 2011
On 02.08.2011 14:22, Dmitry Olshansky wrote:On 02.08.2011 16:18, simendsjo wrote:While changing ctors to templates, I came across another issue (bug?) regarding assignment to immutable (and probably const) members from templated ctors: Error: can only initialize const member v inside constructor Error: template instance t.S2.__ctor!() error instantiating struct S { immutable int v; this(int v) { this.v = v; } } struct S2 { immutable int v; this()(int v) { this.v = v; } } void main() { auto s = S(1); // ok auto s2 = S2(1); // fails }On 02.08.2011 14:13, Dmitry Olshansky wrote:I think there is only one bug: template constructor (and functions IIRC) can't be overloaded with non-template. Both your examples show this bug, since this()(int a){} and this(C)(C c) if(isSomeChar!C) {} are template constructors, while others are not. I think the bug was there for quite some time and likely to be filed already, so check Bugzilla first.On 02.08.2011 16:06, simendsjo wrote:So my first example is a bug, and the second is a wrong error message? Wondering what I should post in a potential bug report, and if it's one or two bugs.On 02.08.2011 13:55, Dmitry Olshansky wrote:Same logic here once you have template constructor, all others need to be template, empty spec is a trick to get anything to be a template. And in this example you really do not need empty spec () in 4.On 02.08.2011 15:06, simendsjo wrote:With the empty templated this, I get other errors though: "t.d(5): Error: constructor t.S.this conflicts with template t.S.__ctor() at t.d(4)" struct S { this()(int a) {} // 4 this(int a, int b) {} // 5 }The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}struct S { this()(uint i) {} this(C)(C c) if(isSomeChar!C) {} } should do it, though it (and workaround) looks like a bug to me.
Aug 02 2011
On 02.08.2011 16:30, simendsjo wrote:On 02.08.2011 14:22, Dmitry Olshansky wrote:Most definitely a bug, you seem to hit a lot of 'em recently :) -- Dmitry OlshanskyOn 02.08.2011 16:18, simendsjo wrote:While changing ctors to templates, I came across another issue (bug?) regarding assignment to immutable (and probably const) members from templated ctors: Error: can only initialize const member v inside constructor Error: template instance t.S2.__ctor!() error instantiating struct S { immutable int v; this(int v) { this.v = v; } } struct S2 { immutable int v; this()(int v) { this.v = v; } } void main() { auto s = S(1); // ok auto s2 = S2(1); // fails }On 02.08.2011 14:13, Dmitry Olshansky wrote:I think there is only one bug: template constructor (and functions IIRC) can't be overloaded with non-template. Both your examples show this bug, since this()(int a){} and this(C)(C c) if(isSomeChar!C) {} are template constructors, while others are not. I think the bug was there for quite some time and likely to be filed already, so check Bugzilla first.On 02.08.2011 16:06, simendsjo wrote:So my first example is a bug, and the second is a wrong error message? Wondering what I should post in a potential bug report, and if it's one or two bugs.On 02.08.2011 13:55, Dmitry Olshansky wrote:Same logic here once you have template constructor, all others need to be template, empty spec is a trick to get anything to be a template. And in this example you really do not need empty spec () in 4.On 02.08.2011 15:06, simendsjo wrote:With the empty templated this, I get other errors though: "t.d(5): Error: constructor t.S.this conflicts with template t.S.__ctor() at t.d(4)" struct S { this()(int a) {} // 4 this(int a, int b) {} // 5 }The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}struct S { this()(uint i) {} this(C)(C c) if(isSomeChar!C) {} } should do it, though it (and workaround) looks like a bug to me.
Aug 02 2011
On 02.08.2011 15:25, Dmitry Olshansky wrote:Most definitely a bug, you seem to hit a lot of 'em recently :)Yeah :( The biggest reason I left D back in the days. Compiler bugs whenever I did anything more than simple tests, and breaking changes with each release so I had to change a lot of code and libraries. This was around 1.007-1.028, so the whole tango/phobos debate was very hot too, and it was hell choosing one for some time due to libraries only supporting one or the other. Now I only use D (and learning D2) for non-critical hobby stuff, so the bugs don't bother me too much. Seeing the enormous progress DMD and phobos has gotten after the move to Github makes me very positive on the future of D though.
Aug 02 2011
On 02.08.2011 15:25, Dmitry Olshansky wrote:On 02.08.2011 16:30, simendsjo wrote:http://d.puremagic.com/issues/show_bug.cgi?id=6427On 02.08.2011 14:22, Dmitry Olshansky wrote:Most definitely a bug, you seem to hit a lot of 'em recently :)On 02.08.2011 16:18, simendsjo wrote:While changing ctors to templates, I came across another issue (bug?) regarding assignment to immutable (and probably const) members from templated ctors: Error: can only initialize const member v inside constructor Error: template instance t.S2.__ctor!() error instantiating struct S { immutable int v; this(int v) { this.v = v; } } struct S2 { immutable int v; this()(int v) { this.v = v; } } void main() { auto s = S(1); // ok auto s2 = S2(1); // fails }On 02.08.2011 14:13, Dmitry Olshansky wrote:I think there is only one bug: template constructor (and functions IIRC) can't be overloaded with non-template. Both your examples show this bug, since this()(int a){} and this(C)(C c) if(isSomeChar!C) {} are template constructors, while others are not. I think the bug was there for quite some time and likely to be filed already, so check Bugzilla first.On 02.08.2011 16:06, simendsjo wrote:So my first example is a bug, and the second is a wrong error message? Wondering what I should post in a potential bug report, and if it's one or two bugs.On 02.08.2011 13:55, Dmitry Olshansky wrote:Same logic here once you have template constructor, all others need to be template, empty spec is a trick to get anything to be a template. And in this example you really do not need empty spec () in 4.On 02.08.2011 15:06, simendsjo wrote:With the empty templated this, I get other errors though: "t.d(5): Error: constructor t.S.this conflicts with template t.S.__ctor() at t.d(4)" struct S { this()(int a) {} // 4 this(int a, int b) {} // 5 }The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}struct S { this()(uint i) {} this(C)(C c) if(isSomeChar!C) {} } should do it, though it (and workaround) looks like a bug to me.
Aug 02 2011
On 02.08.2011 14:22, Dmitry Olshansky wrote:On 02.08.2011 16:18, simendsjo wrote:Yup, old bug. http://d.puremagic.com/issues/show_bug.cgi?id=4749On 02.08.2011 14:13, Dmitry Olshansky wrote:I think there is only one bug: template constructor (and functions IIRC) can't be overloaded with non-template. Both your examples show this bug, since this()(int a){} and this(C)(C c) if(isSomeChar!C) {} are template constructors, while others are not. I think the bug was there for quite some time and likely to be filed already, so check Bugzilla first.On 02.08.2011 16:06, simendsjo wrote:So my first example is a bug, and the second is a wrong error message? Wondering what I should post in a potential bug report, and if it's one or two bugs.On 02.08.2011 13:55, Dmitry Olshansky wrote:Same logic here once you have template constructor, all others need to be template, empty spec is a trick to get anything to be a template. And in this example you really do not need empty spec () in 4.On 02.08.2011 15:06, simendsjo wrote:With the empty templated this, I get other errors though: "t.d(5): Error: constructor t.S.this conflicts with template t.S.__ctor() at t.d(4)" struct S { this()(int a) {} // 4 this(int a, int b) {} // 5 }The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}struct S { this()(uint i) {} this(C)(C c) if(isSomeChar!C) {} } should do it, though it (and workaround) looks like a bug to me.
Aug 02 2011
On 02.08.2011 16:18, simendsjo wrote:http://d.puremagic.com/issues/show_bug.cgi?id=2972 - Jonathan M DavisOn 02.08.2011 14:13, Dmitry Olshansky wrote:I think there is only one bug: template constructor (and functions IIRC) can't be overloaded with non-template. Both your examples show this bug, since this()(int a){} and this(C)(C c) if(isSomeChar!C) {} are template constructors, while others are not. I think the bug was there for quite some time and likely to be filed already, so check Bugzilla first.On 02.08.2011 16:06, simendsjo wrote:So my first example is a bug, and the second is a wrong error message? Wondering what I should post in a potential bug report, and if it's one or two bugs.On 02.08.2011 13:55, Dmitry Olshansky wrote:Same logic here once you have template constructor, all others need to be template, empty spec is a trick to get anything to be a template. And in this example you really do not need empty spec () in 4.On 02.08.2011 15:06, simendsjo wrote:With the empty templated this, I get other errors though: "t.d(5): Error: constructor t.S.this conflicts with template t.S.__ctor() at t.d(4)" struct S { this()(int a) {} // 4 this(int a, int b) {} // 5 }The following program gives me "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with constructor t.S.this at t.d(4)" Is this because char etc can be converted to uint? Shouldn't the template specification make this unambiguous? import std.traits; struct S { this(uint i) {} this(C)(C c) if(isSomeChar!C) {} } void main() {}struct S { this()(uint i) {} this(C)(C c) if(isSomeChar!C) {} } should do it, though it (and workaround) looks like a bug to me.
Aug 02 2011