Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Issue 9650 - __traits(compiles) + mixin #1728

Merged
merged 1 commit into from

2 participants

@9rnsr
Collaborator

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

I couldn't minimize test case, but the bug fix is obvious.

The bug had been hiding for a long time, but recent Phobos change (D-Programming-Language/phobos@2a88fea) had exposed the bug.

When a mixin expression gets invalid code string, the parsing error had not handled correctly. In such case, it had generated invalid AST instead of returning ErrorExp. I guess that the invalid AST would report weird error in later semantic analysis.

I think that both CompileDeclaration and CompileStatement do not have same problem. So they are not changed.

@9rnsr 9rnsr fix Issue 9650 - __traits(compiles) + mixin
I couldn't minimize test case, but the bug fix is obvious.

The bug had been hiding for a long time, but recent Phobos change (D-Programming-Language/phobos@2a88fea) had exposed the bug.

When a mixin expression gets invalid code string, the parsing error had not handled correctly. In such case, it had generated *invalid* AST instead of returning ErrorExp. I guess that the invalid AST would report weird error in later semantic analysis.

I think that both CompileDeclaration and CompileStatement do not have same problem. So they are not changed.
ac89791
@WalterBright WalterBright merged commit 618d827 into from
@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 Mar 8, 2013
  1. @9rnsr

    fix Issue 9650 - __traits(compiles) + mixin

    9rnsr authored
    I couldn't minimize test case, but the bug fix is obvious.
    
    The bug had been hiding for a long time, but recent Phobos change (D-Programming-Language/phobos@2a88fea) had exposed the bug.
    
    When a mixin expression gets invalid code string, the parsing error had not handled correctly. In such case, it had generated *invalid* AST instead of returning ErrorExp. I guess that the invalid AST would report weird error in later semantic analysis.
    
    I think that both CompileDeclaration and CompileStatement do not have same problem. So they are not changed.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 0 deletions.
  1. +3 −0  src/expression.c
View
3  src/expression.c
@@ -6539,7 +6539,10 @@ Expression *CompileExp::semantic(Scope *sc)
p.loc = loc;
p.nextToken();
//printf("p.loc.linnum = %d\n", p.loc.linnum);
+ unsigned errors = global.errors;
Expression *e = p.parseExpression();
+ if (global.errors != errors)
+ return new ErrorExp();
if (p.token.value != TOKeof)
{ error("incomplete mixin expression (%s)", se->toChars());
return new ErrorExp();
Something went wrong with that request. Please try again.