mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Add suggestion for T[] to be []T if a type is allowed in that parsing context
This commit is contained in:
+11
-3
@@ -2739,7 +2739,7 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) {
|
|||||||
while (allow_token(f, Token_Comma)) {
|
while (allow_token(f, Token_Comma)) {
|
||||||
Ast *dummy_name = parse_ident(f);
|
Ast *dummy_name = parse_ident(f);
|
||||||
if (!err_once) {
|
if (!err_once) {
|
||||||
error(dummy_name, "'bit_field' fields do not support multiple names per field");
|
syntax_error(dummy_name, "'bit_field' fields do not support multiple names per field");
|
||||||
err_once = true;
|
err_once = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3299,8 +3299,16 @@ gb_internal Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) {
|
|||||||
open = expect_token(f, Token_OpenBracket);
|
open = expect_token(f, Token_OpenBracket);
|
||||||
|
|
||||||
if (f->curr_token.kind == Token_CloseBracket) {
|
if (f->curr_token.kind == Token_CloseBracket) {
|
||||||
error(f->curr_token, "Expected an operand, got ]");
|
ERROR_BLOCK();
|
||||||
|
syntax_error(f->curr_token, "Expected an operand, got ]");
|
||||||
close = expect_token(f, Token_CloseBracket);
|
close = expect_token(f, Token_CloseBracket);
|
||||||
|
|
||||||
|
if (f->allow_type) {
|
||||||
|
gbString s = expr_to_string(operand);
|
||||||
|
error_line("\tSuggestion: If a type was wanted, did you mean '[]%s'?", s);
|
||||||
|
gb_string_free(s);
|
||||||
|
}
|
||||||
|
|
||||||
operand = ast_index_expr(f, operand, nullptr, open, close);
|
operand = ast_index_expr(f, operand, nullptr, open, close);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -6594,7 +6602,7 @@ gb_internal bool parse_file_tag(const String &lc, const Token &tok, AstFile *f)
|
|||||||
} else if (lc == "no-instrumentation") {
|
} else if (lc == "no-instrumentation") {
|
||||||
f->flags |= AstFile_NoInstrumentation;
|
f->flags |= AstFile_NoInstrumentation;
|
||||||
} else {
|
} else {
|
||||||
error(tok, "Unknown tag '%.*s'", LIT(lc));
|
syntax_error(tok, "Unknown tag '%.*s'", LIT(lc));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user