[Issue 2367] New: Overloading error
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Sep 20 12:10:28 PDT 2008
Jarrett Billingsley wrote:
> On Sat, Sep 20, 2008 at 2:01 PM, <d-bugmail at puremagic.com> wrote:
>> http://d.puremagic.com/issues/show_bug.cgi?id=2367
>>
>> Summary: Overloading error
>> Product: D
>> Version: unspecified
>> Platform: PC
>> OS/Version: Linux
>> Status: NEW
>> Severity: normal
>> Priority: P2
>> Component: DMD
>> AssignedTo: bugzilla at digitalmars.com
>> ReportedBy: andrei at metalanguage.com
>>
>>
>> The following code does not compile:
>>
>> struct S {
>> void foo(in char[] s) {}
>> void foo(in dchar[] s) {}
>> }
>>
>> void main(string[] args) {
>> S s;
>> s.foo("a");
>> }
>>
>> The second overload should not even be considered.
>
> "string literals" do not have a type; they are, in some ways,
> polysemous. They are considered char[], wchar[], or dchar[] based on
> where they're used. If they're used in a situation where it could go
> either way (such as this overloading case), it's an error.
>
> The solution is simple: affix a 'c', 'w', or 'd' to the end of the
> string literal to give it an explicit type.
To facilitate archiving, you may want to post replies to the website
instead.
Andrei
More information about the Digitalmars-d-bugs
mailing list