digitalmars.D.bugs - [Issue 2841] New: char[] template value arguments broken in D2
- d-bugmail puremagic.com (33/33) Apr 16 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2841
- d-bugmail puremagic.com (6/6) Apr 16 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2841
- d-bugmail puremagic.com (21/25) Apr 16 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2841
- d-bugmail puremagic.com (19/19) Sep 22 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2841
- d-bugmail puremagic.com (12/12) Apr 15 2011 http://d.puremagic.com/issues/show_bug.cgi?id=2841
http://d.puremagic.com/issues/show_bug.cgi?id=2841
Summary: char[] template value arguments broken in D2
Product: D
Version: 2.027
Platform: PC
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: regression
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: clugdbug yahoo.com.au
int foo(char[] c)() { return 0; }
void main(){
int a = foo!("abc")();
}
---
fog.d(6): Error: template fog.foo(char[] c) does not match any function
template
declaration
fog.d(6): Error: template fog.foo(char[] c) cannot deduce template function
from
argument types !("abc")()
fog.d(6): Error: template instance errors instantiating template
This all works in D1.042. Fails in D2.028.
The code below is similar. Also for class and union.
--
struct C(char[] c){ }
void main(){
C!("abc") a;
}
--
Apr 16 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2841 Um, string literals are invariant(char)[]. The error message sure sucks, but it's not surprising that this doesn't work. --
Apr 16 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2841
clugdbug yahoo.com.au changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|regression |major
Keywords|rejects-valid |spec
Um,
string literals are invariant(char)[].
Indeed.
The error message sure sucks, but it's not surprising that this doesn't work.
But there is no way that a mutable char [] could be passed as a template value
parameter. And it's not a type. So what is
template(char[] X) ?
int foo(char[] c)() { return 0; }
void main(){
char [] z;
int a = foo!(z)(); // ok
}
I can't see anything in the spec to indicate what this means. From the
.mangleof, it seems to be accepting it as an alias parameter.
OK, I'll change this to a spec error.
--
Apr 16 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2841
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|spec |accepts-invalid
Summary|char[] template value |char[] incorrectly accepted
|arguments broken in D2 |as a template value
| |argument in D2
Severity|major |normal
Here's a test case which illustrates the problem better.
int foo(char[])() { return 0; }
bug.d(1): identifier expected for template value parameter
---
So it clearly thinks it is a template value parameter, but it's impossible in
D2 to have a char[] compile-time value! It must be immutable(char)[].
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 22 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2841
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
The example in comment 2 is fixed in this commit.
https://github.com/donc/dmd/commit/fc67046cf1e66182d959309fb15ef9e2d4c266b9
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 15 2011









d-bugmail puremagic.com 