Skip to content

Commit fa6b6d9

Browse files
committed
Fixes diagnostic error with use, non_intrinsic
Fixes False positive: Object not found in scope in case of "USE, NON_INTRINSIC" #206 A unittest has also been added
1 parent a0f516e commit fa6b6d9

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELONG
22

3+
## 1.14.3
4+
5+
### Fixes
6+
7+
* Fixes parsing of `non_intrinsic` modules
8+
([#206](https://github.com/hansec/fortran-language-server/issues/206))
9+
310
## 1.14.2
411

512
### Fixes

fortls/parse_fortran.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
import io
3838
# Fortran statement matching rules
3939
USE_REGEX = re.compile(
40-
r"[ ]*USE([, ]+INTRINSIC)?[ :]+([a-z0-9_]*)([, ]+ONLY[ :]+)?", re.I
40+
r"[ ]*USE([, ]+(?:INTRINSIC|NON_INTRINSIC))?[ :]+(\w*)([, ]+ONLY[ :]+)?",
41+
re.I,
4142
)
4243
IMPORT_REGEX = re.compile(r"[ ]*IMPORT[ :]+([a-z_])", re.I)
4344
INCLUDE_REGEX = re.compile(r"[ ]*INCLUDE[ :]*[\'\"]([^\'\"]*)", re.I)

test/test_server.py

+6
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def check_return(result_array):
225225
["test_inherit", 2, 0],
226226
["test_int", 2, 0],
227227
["test_mod", 2, 0],
228+
["test_nonint_mod", 2, 0],
228229
["test_program", 2, 0],
229230
["test_rename_sub", 6, 9],
230231
["test_select", 2, 0],
@@ -608,6 +609,11 @@ def test_diagnostic_interfaces():
608609
string += write_rpc_notification(
609610
"textDocument/didOpen", {"textDocument": {"uri": file_path}}
610611
)
612+
# Test that use, non_intrinsic does not raise a diagnostic error
613+
file_path = os.path.join(test_dir, "test_nonintrinsic.f90")
614+
string += write_rpc_notification(
615+
"textDocument/didOpen", {"textDocument": {"uri": file_path}}
616+
)
611617
# Example of a diagnostics message
612618
# string += write_rpc_notification(
613619
# "textDocument/publishDiagnostics",
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module test_nonint_mod
2+
private
3+
integer, parameter, public :: DP = kind(0.0D0)
4+
end module test_nonint_mod
5+
6+
program nonint
7+
use, non_intrinsic :: test_nonint_mod, only : DP
8+
implicit none
9+
real(DP) :: x
10+
x = 0.0_DP
11+
end program nonint

0 commit comments

Comments
 (0)