diff options
| author | gingerBill <bill@gingerbill.org> | 2023-05-30 20:36:43 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-05-30 20:36:43 +0100 |
| commit | 2924e478ee0da20a8c07bf4581bf86a2c53b8eb1 (patch) | |
| tree | 15f19a6f13c99c6c8aa4ad83f89270ebf859bb9b /src/checker.cpp | |
| parent | 297700ad115cae268346f06288d0b3620cd0836b (diff) | |
Improve `check_decl_attributes` logic for `is_runtime`
Diffstat (limited to 'src/checker.cpp')
| -rw-r--r-- | src/checker.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index fd5f8e1e8..fc9a8f776 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -3469,7 +3469,18 @@ gb_internal void check_decl_attributes(CheckerContext *c, Array<Ast *> const &at StringSet set = {}; defer (string_set_destroy(&set)); - bool is_runtime = ((c->scope->parent->flags&(ScopeFlag_File|ScopeFlag_Pkg)) != 0 && c->scope->file->pkg->kind == Package_Runtime); + bool is_runtime = false; + if (c->scope && c->scope->file && (c->scope->flags & ScopeFlag_File) && + c->scope->file->pkg && + c->scope->file->pkg->kind == Package_Runtime) { + is_runtime = true; + } else if (c->scope && c->scope->parent && + (c->scope->flags & ScopeFlag_Proc) && + (c->scope->parent->flags & ScopeFlag_File) && + c->scope->parent->file->pkg && + c->scope->parent->file->pkg->kind == Package_Runtime) { + is_runtime = true; + } for_array(i, attributes) { Ast *attr = attributes[i]; |