mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Improved error messages on Foo a = foo { 1 }; #1496
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
- Safer seed of rand() for WASM without libc.
|
||||
- Bad error message aliasing an ident with a path. #1481.
|
||||
- Error when slicing a struct with an inline array #1488.
|
||||
- Improved error messages on `Foo a = foo { 1 };` #1496
|
||||
|
||||
### Stdlib changes
|
||||
- Additional init functions for hashmap.
|
||||
|
||||
@@ -15,9 +15,14 @@ static Ast *parse_decl_stmt_after_type(ParseContext *c, TypeInfo *type)
|
||||
ast->span = type->span;
|
||||
ast->ast_kind = AST_DECLARE_STMT;
|
||||
ASSIGN_DECL_OR_RET(ast->declare_stmt, parse_local_decl_after_type(c, type), poisoned_ast);
|
||||
Decl *decl = ast->declare_stmt;
|
||||
if (tok_is(c, TOKEN_LBRACE) && decl->var.init_expr && decl->var.init_expr->expr_kind == EXPR_IDENTIFIER)
|
||||
{
|
||||
print_error_at(decl->var.init_expr->span, "An identifier would not usually be followed by a '{'. Did you intend write the name of a type here?");
|
||||
return poisoned_ast;
|
||||
}
|
||||
|
||||
if (tok_is(c, TOKEN_EOS)) return ast;
|
||||
Decl *decl = ast->declare_stmt;
|
||||
if (decl->attributes || decl->var.init_expr)
|
||||
{
|
||||
if (tok_is(c, TOKEN_COMMA) && peek(c) == TOKEN_IDENT)
|
||||
|
||||
Reference in New Issue
Block a user