From 05a3bdad588d7d1194d4705b4f60506208e36b39 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 4 Dec 2020 11:28:14 +0000 Subject: Allow nested procedures to access `@(static)` and `@(thread_local)` variables --- src/check_expr.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/check_expr.cpp') diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 8e09c0320..ea460ce09 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1075,8 +1075,10 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ if (e->parent_proc_decl != nullptr && e->parent_proc_decl != c->curr_proc_decl) { if (e->kind == Entity_Variable) { - error(n, "Nested procedures do not capture its parent's variables: %.*s", LIT(name)); - return nullptr; + if ((e->flags & EntityFlag_Static) == 0) { + error(n, "Nested procedures do not capture its parent's variables: %.*s", LIT(name)); + return nullptr; + } } else if (e->kind == Entity_Label) { error(n, "Nested procedures do not capture its parent's labels: %.*s", LIT(name)); return nullptr; -- cgit v1.2.3