Skip to content

Commit

Permalink
Merge pull request #393 from fortran-lang/fix/issue-265
Browse files Browse the repository at this point in the history
fix/issue 265
  • Loading branch information
gnikit committed May 10, 2024
2 parents e25c46b + dece46a commit e82ce61
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -42,6 +42,8 @@

### Fixed

- Fixed end of scope errors raised by trailing semicolon in native parser
([#265](https://github.com/fortran-lang/fortls/issues/265))
- 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
Expand Down
3 changes: 2 additions & 1 deletion fortls/debug.py
Expand Up @@ -439,7 +439,8 @@ def read_config(root: str | None):

# Check for config files
config_path = locate_config(root)
if not os.path.isfile(config_path):
print(f" Config file = {config_path}")
if config_path is None or not os.path.isfile(config_path):
return pp_suffixes, pp_defs, include_dirs

try:
Expand Down
1 change: 1 addition & 0 deletions fortls/parsers/internal/parser.py
Expand Up @@ -1350,6 +1350,7 @@ def parse(
multi_lines.extendleft(line_stripped.split(";"))
line = multi_lines.pop()
line_stripped = line
line_no_comment = line
# Test for scope end
if file_ast.end_scope_regex is not None:
match = FRegex.END_WORD.match(line_no_comment)
Expand Down
9 changes: 9 additions & 0 deletions test/test_parser.py
Expand Up @@ -39,3 +39,12 @@ def test_private_visibility_interfaces():
err_str, _ = file.load_from_disk()
file.parse()
assert err_str is None


def test_end_scopes_semicolon():
file_path = test_dir / "parse" / "trailing_semicolon.f90"
file = FortranFile(str(file_path))
err_str, _ = file.load_from_disk()
ast = file.parse()
assert err_str is None
assert not ast.end_errors
6 changes: 6 additions & 0 deletions test/test_source/parse/trailing_semicolon.f90
@@ -0,0 +1,6 @@
program trailing_semicolon_in_end_scope
integer :: i
do i=1, 3
print *, "Hello World!"
end do;
end program trailing_semicolon_in_end_scope

0 comments on commit e82ce61

Please sign in to comment.