digitalmars.D.bugs - [Issue 6639] New: Difference beetwen "foo" and "foo"c
- d-bugmail puremagic.com (39/39) Sep 10 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6639
- d-bugmail puremagic.com (15/15) Sep 10 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6639
- d-bugmail puremagic.com (10/10) Sep 10 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6639
- d-bugmail puremagic.com (15/20) Sep 10 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6639
http://d.puremagic.com/issues/show_bug.cgi?id=6639
Summary: Difference beetwen "foo" and "foo"c
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: zeljko.grk gmail.com
After thinking a bit more I have concluded its important consistency issue. So
I reposted it as separate issue.
import std.stdio;
void f(S)(S str){
writeln(str);
}
alias f!(string) fc;
alias f!(wstring) fc;
void main(){
fc("foo"); // L11
//~ fc("foo"c); // works
//~ auto s = "foo";
//~ fc(s); // works
}
//~ Compilation (dmd 2.055) breaks with message:
//~ bug.d(11): Error: function alias bug.f called with argument types:
//~ ((string))
//~ matches both:
//~ bug.f!(string).f(string str)
//~ and:
//~ bug.f!(immutable(wchar)[]).f(immutable(wchar)[] str)
Maybe lexer should annotate string literal without StringPostfix according
source code format?
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 10 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6639
yebblies <yebblies gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |yebblies gmail.com
Resolution| |DUPLICATE
It should work the same for function calls as it does for type deduction: an
untyped string literal should default to immutable(char)[].
Fortunately there's already a patch for this.
*** This issue has been marked as a duplicate of issue 2367 ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 10 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6639 Sorry for duplication. My point is maybe we don’t need unannotated string literal out of lexer. Maybe c is better default, but we need simple rule. Confess I’m not aware of all consequences. Something to think about, maybe? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 10 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6639My point is maybe we don’t need unannotated string literal out of lexer. Maybe c is better default, but we need simple rule. Confess I’m not aware of all consequences. Something to think about, maybe?We actually do need it to be initially untyped. If every string literal was implicitly utf-8, the following functions could not be called with a literal: void fun(wstring s); void fun(dstring s); void fun(const(char)* s); What is important is that a default type can be automatically used, and it already works this way some of the time. auto x = "blah blah"; // x is typed as string Extending this default type to function calls seems natural to me. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 10 2011









d-bugmail puremagic.com 