digitalmars.D.bugs - [Issue 3175] New: rejects templated ref return function
- d-bugmail puremagic.com (38/38) Jul 14 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3175
- d-bugmail puremagic.com (25/25) Nov 18 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3175
- d-bugmail puremagic.com (10/10) Sep 20 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3175
- d-bugmail puremagic.com (24/24) Sep 25 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3175
- d-bugmail puremagic.com (11/11) Sep 27 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3175
- d-bugmail puremagic.com (9/11) Sep 27 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3175
- d-bugmail puremagic.com (13/20) Nov 23 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3175
http://d.puremagic.com/issues/show_bug.cgi?id=3175
Summary: rejects templated ref return function
Product: D
Version: 2.031
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: k-foley onu.edu
import std.stdio;
// This works
//ref int x(int[3] p) { return p[0]; }
// This works
//ref T x(T)(T[3] p) { return p[0]; }
// This does not work
//ref int x(size_t N)(int[N] p) if ( N > 0 ) { return p[0]; }
// This does not work
ref T x(T, size_t N)(T[N] p) if ( N > 0 ) { return p[0]; }
int main()
{
auto a = [1, 2, 3];
a.x = 42;
writeln( a );
return 0;
}
----
$ rdmd test.d
test.d(12): Error: variable test.N only parameters or foreach declarations can
b
e ref
C:\d\dmd.2.031\dmd2\windows\bin\rdmd.exe: Couldn't compile or execute test.d.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3175
Luther Tychonievich <lat7h virginia.edu> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lat7h virginia.edu
Severity|normal |trivial
10:30:44 PST ---
This is only a problem with template parameter deduction:
ref int foo(int x)(int[x] v) if (x>0) { return v[0]; }
foo!(2)([1,2]); // works
foo([1,2]); // gives "only parameters or foreach..." error message
It can be sidestepped by explicit template declaration:
template foo(int x) if (x>0) {
ref int foo(int[x] v) { return v[0]; }
}
foo([1,2]); // works
While obviously not as nice as function template syntax, this workaround is not
difficult to read or write and contains full functionality.
I posit the error message is wrong either way: declarations.c line 908 should
read:
error("only function return types, parameters, and foreach declarations can
be ref");
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3175
Shin Fujishiro <rsinfu gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rsinfu gmail.com
---
*** Issue 4446 has been marked as a duplicate of this issue. ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 20 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3175
Shin Fujishiro <rsinfu gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
Severity|trivial |major
---
Patch against dmd r687. deduceFunctionTemplateMatch() must reset storage class
in parameter's scope as done in matchWithInstance().
--- a/src/template.c
+++ b/src/template.c
-887,6 +887,7 MATCH
TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec
ScopeDsymbol *paramsym = new ScopeDsymbol();
paramsym->parent = scope->parent;
Scope *paramscope = scope->push(paramsym);
+ paramscope->stc = 0;
TemplateTupleParameter *tp = isVariadic();
int tp_is_declared = 0;
Increased the severity as the bug has been repeatedly reported: bug 4041, bug
4446, bug 4934 and comment 2 of bug 2460.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 25 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3175
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugzilla digitalmars.com
19:35:27 PDT ---
Applied the patch http://www.dsource.org/projects/dmd/changeset/695 but the bug
remains.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 27 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3175 ---Applied the patch http://www.dsource.org/projects/dmd/changeset/695 but the bug remains.compile? It's because the type of [1,2,3] has changed to dynamic int[]. Replacing 'auto' to 'int[3]' would make it compile. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 27 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3175
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |clugdbug yahoo.com.au
Resolution| |FIXED
Applied the patch http://www.dsource.org/projects/dmd/changeset/695 but the bug
remains.
compile? It's because the type of [1,2,3] has changed to dynamic int[].
Replacing 'auto' to 'int[3]' would make it compile.
Indeed it does work in DMD2.050.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 23 2010









d-bugmail puremagic.com 