Closed AnsonKoch closed 6 months ago
Can you share the diff of fortls object.py file? Also it would be good if you could form a MWE otherwise it will be hard to replicate
Here's the diff:
diff --git a/fortls/objects.py b/fortls/objects.py
index 7218630..420b6f6 100644
--- a/fortls/objects.py
+++ b/fortls/objects.py
@@ -2288,8 +2288,9 @@ class FortranAST:
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
The minimum working example will take a while to generate, as I'll need to track down what causes the error, but I'll post it if I figure it out.
edit: formatting
Describe the bug When starting fortls from VS Code, within particular arrangements of Fortran source code, fortls crashes with an attribute error. This is traced back to objects.py, in the resolve_includes method, where it is caused by parent_scope being None.
To Reproduce Unsure as to what exactly it is about my source that causes this. Unfortunately, I am unable to share my code here.
Setup information (please complete the following information):
Additional context I edited objects.py by adding an if statement to bypass the problem lines, by checking if parent_scope is not None. This seems to have fixed the problem, but I have not reviewed the fortls code to know if my modification will produce other errors down the road.