Skip to content

Commit e82ce61

Browse files
authored
Merge pull request #393 from fortran-lang/fix/issue-265
fix/issue 265
2 parents e25c46b + dece46a commit e82ce61

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242

4343
### Fixed
4444

45+
- Fixed end of scope errors raised by trailing semicolon in native parser
46+
([#265](https://github.com/fortran-lang/fortls/issues/265))
4547
- Fixed bug where parent scope for includes in AST could be `None`
4648
([#329](https://github.com/fortran-lang/fortls/issues/329))
4749
- Fixed preprocessor bug with `if` and `elif` conditionals

fortls/debug.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ def read_config(root: str | None):
439439

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

445446
try:

fortls/parsers/internal/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,7 @@ def parse(
13501350
multi_lines.extendleft(line_stripped.split(";"))
13511351
line = multi_lines.pop()
13521352
line_stripped = line
1353+
line_no_comment = line
13531354
# Test for scope end
13541355
if file_ast.end_scope_regex is not None:
13551356
match = FRegex.END_WORD.match(line_no_comment)

test/test_parser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,12 @@ def test_private_visibility_interfaces():
3939
err_str, _ = file.load_from_disk()
4040
file.parse()
4141
assert err_str is None
42+
43+
44+
def test_end_scopes_semicolon():
45+
file_path = test_dir / "parse" / "trailing_semicolon.f90"
46+
file = FortranFile(str(file_path))
47+
err_str, _ = file.load_from_disk()
48+
ast = file.parse()
49+
assert err_str is None
50+
assert not ast.end_errors
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
program trailing_semicolon_in_end_scope
2+
integer :: i
3+
do i=1, 3
4+
print *, "Hello World!"
5+
end do;
6+
end program trailing_semicolon_in_end_scope

0 commit comments

Comments
 (0)