hansec / fortran-language-server

Fortran Language Server for the Language Server Protocol
MIT License
295 stars 57 forks source link

Fortran 2003 enum causes fortls to throw exception #167

Closed mystery-e204 closed 3 years ago

mystery-e204 commented 4 years ago

vscode 1.47.3 fortls 1.11.1 python 3.7.3

Fortran 2003 introduced the enum construct (which just binds to the C equivalent):

enum, bind(c)
    enumerator  :: a
    enumerator  :: b
end enum

When starting to type with any such enum in the same scope, an exception is thrown by fortls:

[Error - 10:59:15 AM] Request textDocument/completion failed.
  Message: list index out of range
  Code: -32603 
[object Object]
error handling request {'jsonrpc': '2.0', 'id': 317, 'method': 'textDocument/completion', 'params': {'textDocument': {'uri': 'file:///src/test_fortls.F'}, 'position': {'line': 4, 'character': 2}, 'context': {'triggerKind': 1}}}
Traceback (most recent call last):
  File "/fortls/langserver.py", line 166, in handle
    resp = handler(request)
  File "/fortls/langserver.py", line 662, in serve_autocomplete
    if type_mask[candidate_type]:
IndexError: list index out of range

test_fortls.F simply consists of the above snippet.

hansec commented 3 years ago

Thanks for the report! Sorry for the delay. I just pushed a fix to master and will include it in the next patch release hopefully later today.