Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/issue 265 #393

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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