aboutsummaryrefslogtreecommitdiff
path: root/src/check_stmt.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-02-23 10:37:27 +0000
committergingerBill <bill@gingerbill.org>2020-02-23 10:37:27 +0000
commit5073fcd39ee8693e8a8e781564f7c65184aec1b2 (patch)
tree2c9b623db045b307953b7df0970cad99f823ba01 /src/check_stmt.cpp
parenta72ac6f84140f3cb5f5ed790ec76182efa4f959a (diff)
Improve error message on `using` with procedure parameters #568
Diffstat (limited to 'src/check_stmt.cpp')
-rw-r--r--src/check_stmt.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index c365dca84..bef1919e4 100644
--- a/src/check_stmt.cpp
+++ b/src/check_stmt.cpp
@@ -314,7 +314,11 @@ Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, Operand *rhs)
gbString str = expr_to_string(lhs->expr);
if (e != nullptr && e->flags & EntityFlag_Param) {
- error(lhs->expr, "Cannot assign to '%s' which is a procedure parameter", str);
+ if (e->flags & EntityFlag_Using) {
+ error(lhs->expr, "Cannot assign to '%s' which is from a 'using' procedure parameter", str);
+ } else {
+ error(lhs->expr, "Cannot assign to '%s' which is a procedure parameter", str);
+ }
} else {
error(lhs->expr, "Cannot assign to '%s'", str);
}
@@ -497,6 +501,8 @@ bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, b
Entity *f = found->elements.entries[i].value;
if (f->kind == Entity_Variable) {
Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, expr);
+ if (e->flags & EntityFlag_Value) uvar->flags |= EntityFlag_Value;
+ if (e->flags & EntityFlag_Param) uvar->flags |= EntityFlag_Param;
Entity *prev = scope_insert(ctx->scope, uvar);
if (prev != nullptr) {
gbString expr_str = expr_to_string(expr);