changeset 1177:a8b9fc41c34b

Fix #246 by running type->semantic() on parameters so tuples are expanded.
author Frits van Bommel <fvbommel wxs.nl>
date Sun, 29 Mar 2009 23:57:51 +0200
parents 34321f120882
children a668f4051368
files dmd/func.c
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/func.c	Sun Mar 29 19:46:37 2009 +0200
+++ b/dmd/func.c	Sun Mar 29 23:57:51 2009 +0200
@@ -769,6 +769,30 @@
 	    }
 	}
 
+#if IN_LLVM
+        // LDC make sure argument type is semanticed.
+        // Turns TypeTuple!(int, int) into two int parameters, for instance.
+        if (f->parameters)
+        {
+            for (size_t i = 0; i < Argument::dim(f->parameters); i++)
+	    {	Argument *arg = (Argument *)Argument::getNth(f->parameters, i);
+                Type* nw = arg->type->semantic(0, sc);
+                if (arg->type != nw) {
+                    arg->type = nw;
+                    // Examine this index again.
+                    // This is important if it turned into a tuple.
+                    // In particular, the empty tuple should be handled or the
+                    // next parameter will be skipped.
+                    // FIXME: Maybe we only need to do this for tuples,
+                    //        and can add tuple.length after decrement?
+                    i--;
+                }
+            }
+            // update nparams to include expanded tuples
+            nparams = Argument::dim(f->parameters);
+        }
+#endif
+
 	// Propagate storage class from tuple parameters to their element-parameters.
 	if (f->parameters)
 	{