From 8b511d54b5a7ceb4eec4b17ff8ea70a1f8da1e72 Mon Sep 17 00:00:00 2001 From: gnikit Date: Fri, 10 May 2024 14:41:12 +0100 Subject: [PATCH] chore: Fix parent scope issue in FortranAST class Fixes #329 --- CHANGELOG.md | 2 ++ fortls/parsers/internal/ast.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 148915d4..cf515b3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,8 @@ ### Fixed +- Fixed bug where parent scope for includes in AST could be `None` + ([#329](https://github.com/fortran-lang/fortls/issues/329)) - Fixed preprocessor bug with `if` and `elif` conditionals ([#322](https://github.com/fortran-lang/fortls/issues/322)) - Fixed bug where type fields or methods were not detected if spaces were diff --git a/fortls/parsers/internal/ast.py b/fortls/parsers/internal/ast.py index 61b36838..94bf448f 100644 --- a/fortls/parsers/internal/ast.py +++ b/fortls/parsers/internal/ast.py @@ -272,8 +272,9 @@ def resolve_includes(self, workspace, path: str | None = None): added_entities = [] for child in include_ast.inc_scope.children: added_entities.append(child) - parent_scope.add_child(child) - child.update_fqsn(parent_scope.FQSN) + if parent_scope is not None: + parent_scope.add_child(child) + child.update_fqsn(parent_scope.FQSN) include_ast.none_scope = parent_scope inc.scope_objs = added_entities