Skip to content

Commit

Permalink
fix Issue 15127 - Parser assertion on wrong code
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Sep 30, 2015
1 parent 5b0471d commit e9ca948
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,7 @@ public:
TemplateParameters* tpl = null;
if (token.value == TOKlparen)
tpl = parseTemplateParameterList();
assert(token.value == TOKassign);
nextToken(); // skip over '='
check(TOKassign); // skip over '='
Initializer _init = parseInitializer();
auto v = new VarDeclaration(loc, null, ident, _init);
v.storage_class = storageClass;
Expand Down
20 changes: 20 additions & 0 deletions test/fail_compilation/ice15127.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice15127.d(17): Error: basic type expected, not struct
fail_compilation/ice15127.d(17): Error: identifier expected for template value parameter
fail_compilation/ice15127.d(17): Error: found 'struct' when expecting ')'
fail_compilation/ice15127.d(17): Error: found 'ExampleStruct' when expecting '='
fail_compilation/ice15127.d(17): Error: semicolon expected following auto declaration, not ')'
fail_compilation/ice15127.d(17): Error: declaration expected, not ')'
---
*/

struct ExampleStruct(S) { }

template ExampleTemplate(K)
{
enum ExampleTemplate(struct ExampleStruct(K)) = K;
}

void main() {}

0 comments on commit e9ca948

Please sign in to comment.