View mode: basic / threaded / horizontal-split · Log in · Help
August 02, 2011
Re: Template specification conflict
On 02.08.2011 14:22, Dmitry Olshansky wrote:
> On 02.08.2011 16:18, simendsjo wrote:
>> On 02.08.2011 14:13, Dmitry Olshansky wrote:
>>> On 02.08.2011 16:06, simendsjo wrote:
>>>> On 02.08.2011 13:55, Dmitry Olshansky wrote:
>>>>> 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.
>>>>>
>>>>
>>>> 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
>>>> }
>>>>
>>> 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.
>>>
>>
>> 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.
> 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.
>


Yup, old bug.
http://d.puremagic.com/issues/show_bug.cgi?id=4749
August 02, 2011
Re: Template specification conflict
> On 02.08.2011 16:18, simendsjo wrote:
> > On 02.08.2011 14:13, Dmitry Olshansky wrote:
> >> On 02.08.2011 16:06, simendsjo wrote:
> >>> On 02.08.2011 13:55, Dmitry Olshansky wrote:
> >>>> 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.
> >>> 
> >>> 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
> >>> }
> >> 
> >> 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.
> > 
> > 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.
> 
> 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.

http://d.puremagic.com/issues/show_bug.cgi?id=2972

- Jonathan M Davis
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home