Skip to content

Commit

Permalink
Merge pull request #5143 from 9rnsr/fix15127
Browse files Browse the repository at this point in the history
Issue 15127 - Parser assertion on wrong code
  • Loading branch information
yebblies committed Sep 30, 2015
2 parents 5b0471d + e9ca948 commit eb1c764
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
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
@@ -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 eb1c764

Please sign in to comment.