From 972fca57297549cb0a74d063a5b12bc90e15f181 Mon Sep 17 00:00:00 2001 From: Frits van Bommel Date: Sun, 29 Mar 2009 23:57:51 +0200 Subject: [PATCH] Fix #246 by running type->semantic() on parameters so tuples are expanded. --- dmd/func.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dmd/func.c b/dmd/func.c index 3b93eb56..6b596158 100644 --- a/dmd/func.c +++ b/dmd/func.c @@ -769,6 +769,30 @@ void FuncDeclaration::semantic3(Scope *sc) } } +#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) {