Skip to content

Commit e3c2ff3

Browse files
committed
refactor: improve error handling in preprocessor IF statement evaluation
Now throws fortls exception
1 parent 254ac6c commit e3c2ff3

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

fortls/parsers/internal/parser.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,11 +2075,10 @@ def replace_vars(line: str):
20752075
if defs is None:
20762076
defs = {}
20772077
try:
2078-
line_res = eval(replace_ops(replace_vars(replace_defined(text))))
2079-
except:
2080-
return False
2081-
else:
2082-
return line_res
2078+
return eval(replace_ops(replace_vars(replace_defined(text))))
2079+
except Exception as exc:
2080+
log.error("Error evaluating preprocessor IF statement: %s", exc)
2081+
raise ParserError(exc) from exc
20832082

20842083
def expand_func_macro(def_name: str, def_value: tuple[str, str]):
20852084
def_args, sub = def_value

0 commit comments

Comments
 (0)