Skip to content

Commit 6f473d3

Browse files
committed
bug: incomplete submodule setting name to None
The submodule AST node was setting the name of the object to None instead of an empty string which caused havoc in all sorts of places. Fixes #233
1 parent c1278cd commit 6f473d3

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

fortls/langserver.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,12 @@ def map_types(type, in_class: bool = False):
301301
# Add scopes to outline view
302302
test_output = []
303303
for scope in file_obj.ast.get_scopes():
304-
if (scope.name[0] == "#") or (scope.get_type() == SELECT_TYPE_ID):
304+
305+
if (
306+
not scope.name
307+
or scope.name[0] == "#"
308+
or scope.get_type() == SELECT_TYPE_ID
309+
):
305310
continue
306311
scope_tree = scope.FQSN.split("::")
307312
if len(scope_tree) > 2:

fortls/objects.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ def __init__(
745745
file_ast: FortranAST,
746746
line_number: int,
747747
name: str,
748-
ancestor_name: str = None,
748+
ancestor_name: str = "",
749749
):
750750
super().__init__(file_ast, line_number, name)
751751
self.ancestor_name = ancestor_name
@@ -766,7 +766,7 @@ def get_ancestors(self):
766766
return []
767767

768768
def resolve_inherit(self, obj_tree, inherit_version):
769-
if self.ancestor_name is None:
769+
if not self.ancestor_name:
770770
return
771771
if self.ancestor_name in obj_tree:
772772
self.ancestor_obj = obj_tree[self.ancestor_name][0]

fortls/parse_fortran.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@ def read_submod_def(line: str):
586586
if submod_match is None:
587587
return None
588588

589-
parent_name: str = None
590-
name: str = None
589+
parent_name: str = ""
590+
name: str = ""
591591
trailing_line = line[submod_match.end(0) :].split("!")[0]
592592
trailing_line = trailing_line.strip()
593593
parent_match = FRegex.WORD.match(trailing_line)

0 commit comments

Comments
 (0)