From 5073fcd39ee8693e8a8e781564f7c65184aec1b2 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 23 Feb 2020 10:37:27 +0000 Subject: Improve error message on `using` with procedure parameters #568 --- src/check_stmt.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/check_stmt.cpp') 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); -- cgit v1.2.3