Closed
Description
Describe the bug
Given a nested pre-processor block like this:
#if 0
#if 1
#define FOO 1
#endif
#endif
FOO
is incorrectly defined to 1
. fortls
seems to only take the innermost #if
into account and ignores that the outer #if
statement evaluates to false
.
To Reproduce
Given the example above is written to a file pp-nested-if.F90
. Executing
python -m fortls --debug_filepath=pp-nested-if.F90 --debug_parser
gives
=== PreProc Pass ===
#if 0 !!! Conditional FALSE(1)
#if 1 !!! Conditional TRUE(2)
#define FOO 1 !!! Define statement(3)
#endif !!! Conditional TRUE/END(4)
#endif !!! Conditional FALSE/END(5)
=== Parsing Pass ===
which shows that the line #define FOO 1
is evaluated.
Expected behavior
FOO
should not be defined.
Setup information (please complete the following information):
- OS: Windows
- Python Version 3.11
- fortls Version 3.1.1.dev