Permalink
Browse files

fix Issue 9208 - [ICE](func.c line 1205) with auto return in recursiv…

…e function
  • Loading branch information...
1 parent 117dbe3 commit 0e58a5ac9b87183c8ed396c0d570163bb0f6fdaf @9rnsr 9rnsr committed Dec 26, 2012
Showing with 22 additions and 1 deletion.
  1. +6 −1 src/template.c
  2. +16 −0 test/compilable/test9209.d
View
@@ -2245,11 +2245,16 @@ FuncDeclaration *TemplateDeclaration::deduceFunctionTemplate(Scope *sc, Loc loc,
/* As Bugzilla 3682 shows, a template instance can be matched while instantiating
* that same template. Thus, the function type can be incomplete. Complete it.
+ *
+ * Bugzilla 9208: For auto function, completion should be deferred to the end of
+ * its semantic3. Should not complete it in here.
*/
{ TypeFunction *tf = (TypeFunction *)fd_best->type;
assert(tf->ty == Tfunction);
- if (tf->next)
+ if (tf->next && !fd_best->inferRetType)
+ {
fd_best->type = tf->semantic(loc, sc);
+ }
}
if (fd_best->scope)
{
View
@@ -0,0 +1,16 @@
+// PERMUTE_ARGS:
+
+// 9209
+
+auto array(T)(T t){ return t; }
+
+auto bar()(in int* x)
+{
+ if (true) return 0;
+ return array(bar(x));
+}
+
+void main ()
+{
+ bar(null);
+}

0 comments on commit 0e58a5a

Please sign in to comment.