digitalmars.D.bugs - [Issue 3294] New: forward reference to inferred return type of function call
- d-bugmail puremagic.com (45/45) Sep 03 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3294
- d-bugmail puremagic.com (76/76) May 11 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3294
- d-bugmail puremagic.com (12/12) Aug 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3294
- d-bugmail puremagic.com (13/13) Aug 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3294
- d-bugmail puremagic.com (11/11) Aug 11 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3294
http://d.puremagic.com/issues/show_bug.cgi?id=3294
Summary: forward reference to inferred return type of function
call
Product: D
Version: 2.031
Platform: Other
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: 2korden gmail.com
module Test;
struct SomeInfiniteRange
{
int front() { return 42; }
enum empty = false;
void popFront() {}
}
struct SomeContainer(T)
{
auto opSlice()
{
return SomeInfiniteRange();
}
}
class Test
{
void test()
{
foreach (int f; _foo[]) {
// do nothing
}
}
private SomeContainer!(int) _foo;
}
Test.d(23): Error: forward reference to inferred return type of function call
this._foo.opSlice()
Test.d(23): Error: foreach: int is not an aggregate type
Note that the code compiles just fine if SomeContainer is a concrete struct
(not a template)
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3294
Rainer Schuetze <r.sagitario gmx.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch, rejects-valid
CC| |r.sagitario gmx.de
PDT ---
missing. The patch is a bit more complicated, though, because the function
declaration is not available were it is needed, so it has to be added as an
argument to functionParameters():
Index: expression.c
===================================================================
--- expression.c (revision 483)
+++ expression.c (working copy)
-642,7 +642,7
*/
Type *functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
- Expressions *arguments)
+ Expressions *arguments, FuncDeclaration* fd)
{
//printf("functionParameters()\n");
assert(arguments);
-931,6 +931,11
arguments->dim - nparams);
arguments->insert(0, e);
}
+
+ // if inferring return type, semantic3 needs to be run
+ if(!tf->next && fd->inferRetType)
+ fd->semantic3(fd->scope);
+
Type *tret = tf->next;
if (wildmatch)
{ /* Adjust function return type based on wildmatch
-3972,7 +3977,7
if (!arguments)
arguments = new Expressions();
- functionParameters(loc, sc, tf, arguments);
+ functionParameters(loc, sc, tf, arguments, f);
type = type->addMod(tf->nextOf()->mod);
}
-3997,7 +4002,7
assert(allocator);
tf = (TypeFunction *)f->type;
- functionParameters(loc, sc, tf, newargs);
+ functionParameters(loc, sc, tf, newargs, f);
}
else
{
-4029,7 +4034,7
if (!arguments)
arguments = new Expressions();
- functionParameters(loc, sc, tf, arguments);
+ functionParameters(loc, sc, tf, arguments, f);
}
else
{
-4053,7 +4058,7
assert(allocator);
tf = (TypeFunction *)f->type;
- functionParameters(loc, sc, tf, newargs);
+ functionParameters(loc, sc, tf, newargs, f);
#if 0
e = new VarExp(loc, f);
e = new CallExp(loc, e, newargs);
-7254,7 +7259,7
if (!arguments)
arguments = new Expressions();
- type = functionParameters(loc, sc, tf, arguments);
+ type = functionParameters(loc, sc, tf, arguments, f);
if (!type)
{
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 11 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3294
David Simcha <dsimcha yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |dsimcha yahoo.com
Resolution| |FIXED
Fixed 2.048
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3294
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
CC| |bugzilla digitalmars.com
Resolution|FIXED |
21:19:36 PDT ---
Although the test case works now, the bug isn't fixed properly. I need to undo
my fix and use Rainer's.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3294
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
23:11:06 PDT ---
http://www.dsource.org/projects/dmd/changeset/616
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 11 2010









d-bugmail puremagic.com 