diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2022-10-17 11:45:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-17 11:45:57 +0100 |
| commit | 58e607e9600979db2fd746d026042e8cb6c4ebc8 (patch) | |
| tree | 1a9ba214bc1b0ddb31c53423f5720c7d01db6641 /src | |
| parent | 412ca362304da61aa73637eeb52f2f2e7ce34d1a (diff) | |
| parent | 73c1f08776688f18940abcbff5d5b9f0f594049d (diff) | |
Merge pull request #2128 from Lperlind/staging/better_using_blank
Fix assert in issue #1555 and improve error messages with 'using _'
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_decl.cpp | 5 | ||||
| -rw-r--r-- | src/check_stmt.cpp | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 9d043e60a..bb56749af 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -1488,6 +1488,11 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty if (!(e->flags & EntityFlag_Using)) { 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); String name = e->token.string; Type *t = base_type(type_deref(e->type)); diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 630182273..9cacb4a35 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -584,7 +584,11 @@ void check_label(CheckerContext *ctx, Ast *label, Ast *parent) { // Returns 'true' for 'continue', 'false' for 'return' bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, bool is_selector, Entity *e) { if (e == nullptr) { - error(us->token, "'using' applied to an unknown entity"); + 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"); + } return true; } |