Mercurial > projects > ldc
comparison dmd/func.c @ 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 | 08c1c3bfea5a |
children | e961851fb8be |
comparison
equal
deleted
inserted
replaced
1176:34321f120882 | 1177:a8b9fc41c34b |
---|---|
766 argptr->semantic(sc2); | 766 argptr->semantic(sc2); |
767 sc2->insert(argptr); | 767 sc2->insert(argptr); |
768 argptr->parent = this; | 768 argptr->parent = this; |
769 } | 769 } |
770 } | 770 } |
771 | |
772 #if IN_LLVM | |
773 // LDC make sure argument type is semanticed. | |
774 // Turns TypeTuple!(int, int) into two int parameters, for instance. | |
775 if (f->parameters) | |
776 { | |
777 for (size_t i = 0; i < Argument::dim(f->parameters); i++) | |
778 { Argument *arg = (Argument *)Argument::getNth(f->parameters, i); | |
779 Type* nw = arg->type->semantic(0, sc); | |
780 if (arg->type != nw) { | |
781 arg->type = nw; | |
782 // Examine this index again. | |
783 // This is important if it turned into a tuple. | |
784 // In particular, the empty tuple should be handled or the | |
785 // next parameter will be skipped. | |
786 // FIXME: Maybe we only need to do this for tuples, | |
787 // and can add tuple.length after decrement? | |
788 i--; | |
789 } | |
790 } | |
791 // update nparams to include expanded tuples | |
792 nparams = Argument::dim(f->parameters); | |
793 } | |
794 #endif | |
771 | 795 |
772 // Propagate storage class from tuple parameters to their element-parameters. | 796 // Propagate storage class from tuple parameters to their element-parameters. |
773 if (f->parameters) | 797 if (f->parameters) |
774 { | 798 { |
775 for (size_t i = 0; i < f->parameters->dim; i++) | 799 for (size_t i = 0; i < f->parameters->dim; i++) |