Permalink
Browse files

Merge pull request #1410 from 9rnsr/fix9208

Issue 9208 - [ICE](func.c line 1205) with auto return in recursive function
  • Loading branch information...
2 parents 99e93a6 + 0e58a5a commit b07e16196afa0bacb6335d33812e2ebb6a0fdfa6 @WalterBright WalterBright committed Jan 3, 2013
Showing with 47 additions and 1 deletion.
  1. +6 −1 src/template.c
  2. +20 −0 test/compilable/a3682.d
  3. +5 −0 test/compilable/imports/b3682.d
  4. +16 −0 test/compilable/test9209.d
View
7 src/template.c
@@ -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
20 test/compilable/a3682.d
@@ -0,0 +1,20 @@
+// EXTRA_SOURCES: imports/b3682.d
+// PERMUTE_ARGS:
+
+// 3682
+
+struct Tuple(Types...)
+{
+ Tuple!(Types[0..1]) slice()()
+ {
+ Tuple!(Types[0..1]) x;
+ return x;
+ }
+
+ void fail()
+ {
+ Tuple!(float, double, int) a;
+ auto s = a.slice();
+ static assert(is(typeof(s) == Tuple!(float)));
+ }
+}
View
5 test/compilable/imports/b3682.d
@@ -0,0 +1,5 @@
+module imports.b3682;
+
+import a3682;
+alias Tuple!(int) tint;
+
View
16 test/compilable/test9209.d
@@ -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 b07e161

Please sign in to comment.