commit 1d12f4143e87548b8f876f7ecd336c8eb0255679
parent 479e831dc371ae0549ad5e28929f9c999d52f107
Author: Drew DeVault <sir@cmpwn.com>
Date: Mon, 1 Feb 2021 12:10:23 -0500
parse: fix error with match on type alias
Diffstat:
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/parse.c b/src/parse.c
@@ -1728,6 +1728,7 @@ parse_match_expression(struct lexer *lexer)
*next_case = xcalloc(1, sizeof(struct ast_match_case));
struct token tok2 = {0};
+ struct identifier ident = {0};
switch (lex(lexer, &tok)) {
case T_NAME:
switch (lex(lexer, &tok2)) {
@@ -1736,14 +1737,11 @@ parse_match_expression(struct lexer *lexer)
_case->type = parse_type(lexer);
break;
case T_DOUBLE_COLON:
- _case->type = parse_type(lexer);
- synassert(_case->type->storage == TYPE_STORAGE_ALIAS,
- &tok, T_NAME, T_EOF);
- struct identifier ident = {
- .name = tok.name, // Assumes ownership
- .ns = xcalloc(1, sizeof(struct identifier)),
- };
- *ident.ns = _case->type->alias;
+ ident.ns = xcalloc(1, sizeof(struct identifier));
+ ident.ns->name = tok.name; // Assumes ownership
+ parse_identifier(lexer, &ident);
+ _case->type = mktype(&tok.loc);
+ _case->type->storage = TYPE_STORAGE_ALIAS;
_case->type->alias = ident;
break;
case T_CASE: