[Issue 3294] forward reference to inferred return type of function call
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 11 13:23:30 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3294
Rainer Schuetze <r.sagitario at gmx.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch, rejects-valid
CC| |r.sagitario at gmx.de
--- Comment #1 from Rainer Schuetze <r.sagitario at gmx.de> 2010-05-11 13:23:29 PDT ---
This one is a similar to #2810, i.e. the type inferring of the function is
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: -------
More information about the Digitalmars-d-bugs
mailing list