diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ad223fe..c4d51aa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELONG +## 2.2.10 + +### Fixed + +- Fixes GoTo Implementation error for intrinsics + ([#80](https://github.com/gnikit/fortls/issues/80)) + ## 2.2.9 ### Changed diff --git a/fortls/langserver.py b/fortls/langserver.py index a03e3248..9c3e825f 100644 --- a/fortls/langserver.py +++ b/fortls/langserver.py @@ -1122,6 +1122,9 @@ def serve_implementation(self, request: dict): var_obj = self.get_definition(file_obj, def_line, def_char) if var_obj is None: return None + # Intrinsics do not have implementations we can access + if isinstance(var_obj, fortran_intrinsic_obj): + return None # Construct implementation reference if var_obj.parent.get_type() == CLASS_TYPE_ID: impl_obj = var_obj.link_obj diff --git a/test/test_server_implementation.py b/test/test_server_implementation.py index 969b7ab6..65a3ddec 100644 --- a/test/test_server_implementation.py +++ b/test/test_server_implementation.py @@ -35,3 +35,43 @@ def test_implementation_type_bound(): errcode, results = run_request(string, ["-n", "1"]) assert errcode == 0 assert results[1] == create(test_dir / "subdir" / "test_free.f90", 49, 11, 28) + + +def test_implementation_intrinsics(): + """Go to implementation of implicit methods is handled gracefully""" + string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")}) + file_path = test_dir / "rename" / "test_rename_intrinsic.f90" + string += imp_request(file_path, 11, 18) + errcode, results = run_request(string, ["-n", "1"]) + assert errcode == 0 + assert results[1] is None + + +def test_implementation_integer(): + """Go to implementation when no implementation is present is handled gracefully""" + string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")}) + file_path = test_dir / "rename" / "test_rename_intrinsic.f90" + string += imp_request(file_path, 20, 31) + errcode, results = run_request(string, ["-n", "1"]) + assert errcode == 0 + assert results[1] is None + + +def test_implementation_empty(): + """Go to implementation for empty lines is handled gracefully""" + string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")}) + file_path = test_dir / "rename" / "test_rename_intrinsic.f90" + string += imp_request(file_path, 13, 0) + errcode, results = run_request(string, ["-n", "1"]) + assert errcode == 0 + assert results[1] is None + + +def test_implementation_no_file(): + """Go to implementation for empty lines is handled gracefully""" + string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")}) + file_path = test_dir / "rename" / "fake.f90" + string += imp_request(file_path, 13, 0) + errcode, results = run_request(string, ["-n", "1"]) + assert errcode == 0 + assert results[1] is None