mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 22:58:46 +00:00
Merge pull request #2128 from Lperlind/staging/better_using_blank
Fix assert in issue #1555 and improve error messages with 'using _'
This commit is contained in:
@@ -1488,6 +1488,11 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
|
|||||||
if (!(e->flags & EntityFlag_Using)) {
|
if (!(e->flags & EntityFlag_Using)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (is_blank_ident(e->token)) {
|
||||||
|
error(e->token, "'using' a procedure parameter requires a non blank identifier");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
bool is_value = (e->flags & EntityFlag_Value) != 0 && !is_type_pointer(e->type);
|
bool is_value = (e->flags & EntityFlag_Value) != 0 && !is_type_pointer(e->type);
|
||||||
String name = e->token.string;
|
String name = e->token.string;
|
||||||
Type *t = base_type(type_deref(e->type));
|
Type *t = base_type(type_deref(e->type));
|
||||||
|
|||||||
@@ -584,7 +584,11 @@ void check_label(CheckerContext *ctx, Ast *label, Ast *parent) {
|
|||||||
// Returns 'true' for 'continue', 'false' for 'return'
|
// Returns 'true' for 'continue', 'false' for 'return'
|
||||||
bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, bool is_selector, Entity *e) {
|
bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, bool is_selector, Entity *e) {
|
||||||
if (e == nullptr) {
|
if (e == nullptr) {
|
||||||
|
if (is_blank_ident(expr)) {
|
||||||
|
error(us->token, "'using' in a statement is not allowed with the blank identifier '_'");
|
||||||
|
} else {
|
||||||
error(us->token, "'using' applied to an unknown entity");
|
error(us->token, "'using' applied to an unknown entity");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user