Skip to content

Commit

Permalink
refactor: improve error handling in preprocessor IF statement evaluation
Browse files Browse the repository at this point in the history
Now throws fortls exception
  • Loading branch information
gnikit committed Apr 28, 2024
1 parent 5a4743b commit 21a29d6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions fortls/parsers/internal/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2075,11 +2075,10 @@ def replace_vars(line: str):
if defs is None:
defs = {}
try:
line_res = eval(replace_ops(replace_vars(replace_defined(text))))
except:
return False
else:
return line_res
return eval(replace_ops(replace_vars(replace_defined(text))))
except Exception as exc:
log.error("Error evaluating preprocessor IF statement: %s", exc)
raise ParserError(exc) from exc

Check warning on line 2081 in fortls/parsers/internal/parser.py

View check run for this annotation

Codecov / codecov/patch

fortls/parsers/internal/parser.py#L2079-L2081

Added lines #L2079 - L2081 were not covered by tests

def expand_func_macro(def_name: str, def_value: tuple[str, str]):
def_args, sub = def_value
Expand Down

0 comments on commit 21a29d6

Please sign in to comment.