Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

8982 ICE(ctfeexpr.c) __parameters of an erroneous default parameter #1453

Merged
merged 1 commit into from

2 participants

@donc
Collaborator

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).

@donc donc Fix issue 8982 ICE(ctfeexpr.c) __parameters of an erroneous default p…
…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).
d71cf04
@9rnsr
Collaborator

LGTM.

@9rnsr 9rnsr merged commit bc8b981 into D-Programming-Language:master
@donc donc deleted the donc:ice8982ctfe__parameters branch
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 9, 2013
  1. @donc

    Fix issue 8982 ICE(ctfeexpr.c) __parameters of an erroneous default p…

    donc authored
    …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).
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 0 deletions.
  1. +6 −0 src/expression.c
  2. +15 −0 test/compilable/compile1.d
View
6 src/expression.c
@@ -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));
View
15 test/compilable/compile1.d
@@ -22,6 +22,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
**************************************************/
static assert(!is(typeof( { bool __ctfe= true; })));
Something went wrong with that request. Please try again.