parser: adjust location info for variable_decl

This commit is contained in:
tocariimaa 2025-01-21 19:42:07 -03:00
parent 7c286f2261
commit 828b84e1cc

View file

@ -255,10 +255,10 @@ variable_decl(ParserState *ps, enum LexTokenId decl_kind)
};
Assert(decl_kind == T_LET || decl_kind == T_VAR || decl_kind == T_CONST);
Ast *decl = make_tree(AST_VARDECL, ps->lexer->cur_loc);
LexToken token = lex_scan(ps->lexer);
lex_match(ps->lexer, &token, T_IDENT);
Ast *decl = make_tree(AST_VARDECL, ps->lexer->cur_loc);
decl->var = (AstVarDecl) {
.name = token.ident,
.kind = Token2SemaVarKind[decl_kind],
@ -271,7 +271,7 @@ variable_decl(ParserState *ps, enum LexTokenId decl_kind)
parse_error(ps, "expected a type, got %s instead", TokenIdStr[token.id]);
return nil;
}
decl->var.datatype = make_ident_node(token.ident, ps->lexer->cur_loc);
decl->var.datatype = make_ident_node(token.ident, token.loc);
}
/* assignment expression */