Skip to content

Commit

Permalink
Fix issue 8982 ICE(ctfeexpr.c) __parameters of an erroneous default p…
Browse files Browse the repository at this point in the history
…arameter

Don't create a tuple with an error in it; instead, return an ErrorExp.
This is the same behaviour you get when creating a erroneous tuple by normal means.

(The test case is wrapped in a speculative template so that the module compiles even though
it contains an error).
  • Loading branch information
don-clugston-sociomantic committed Jan 9, 2013
1 parent c9bdd19 commit d71cf04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/expression.c
Expand Up @@ -5989,6 +5989,12 @@ Expression *IsExp::semantic(Scope *sc)
for (size_t i = 0; i < dim; i++)
{ Parameter *arg = Parameter::getNth(params, i);
assert(arg && arg->type);
/* If one of the default arguments was an error,
don't return an invalid tuple
*/
if (tok2 == TOKparameters && arg->defaultArg &&
arg->defaultArg->op == TOKerror)
return new ErrorExp();
args->push(new Parameter(arg->storageClass, arg->type,
(tok2 == TOKparameters) ? arg->ident : NULL,
(tok2 == TOKparameters) ? arg->defaultArg : NULL));
Expand Down
15 changes: 15 additions & 0 deletions test/compilable/compile1.d
Expand Up @@ -21,6 +21,21 @@ auto segfault8532(Y, R ...)(R r, Y val) pure

static assert(!is(typeof( segfault8532(1,2,3))));

/**************************************************
8982 ICE(ctfeexpr.c) __parameters with error in default value
**************************************************/
template ice8982(T)
{
void bug8982(ref const int v = 7){}

static if (is(typeof(bug8982) P == __parameters)) {
pragma(msg, ((P[0..1] g) => g[0])());
}
}

static assert(!is(ice8982!(int)));


/**************************************************
8801 ICE assigning to __ctfe
**************************************************/
Expand Down

0 comments on commit d71cf04

Please sign in to comment.