http://d.puremagic.com/issues/show_bug.cgi?id=2862


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Summary|ICE: assert                 |ICE(template.c) using type
                   |template.c(4048)            |tuple as function argument
                   |global.errors               |


--- Comment #2 from Don <clugd...@yahoo.com.au> 2009-10-23 01:01:17 PDT ---
Root cause: should not be able to use a type as a function parameter.
Currently, error messages are generated in the back-end, but some cases are
missed. This moves the error message to the front-end where it belongs.
---
Example of backend error now moved to front-end:
void foo(int x){}

alias int BAD;
void main(){
  foo(BAD);
}
---
And also note that non-type tuples are OK as function parameters. This test
case still passes.
int foo(T...)(T t) { return t[0]+t[1]; }
template bug(T...){
   int x = foo(T) + 4;
}

void main(){
  int z = bug!(1, 2).x;
  assert(z==7);
}
---



Index: expression.c
===================================================================
--- expression.c    (revision 215)
+++ expression.c    (working copy)
@@ -462,7 +462,10 @@

     for (size_t i = 0; i < exps->dim; i++)
     {   Expression *arg = (Expression *)exps->data[i];
-
+        if (arg->op == TOKtype)
+        {    arg->error("type %s is not an expression", arg->toChars());
+        arg = new IntegerExp(arg->loc, 0, Type::tint32);
+        }
         if (!arg->type)
         {

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to