1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-23 23:30:22 +00:00

Fix nested #ifs

This commit is contained in:
Karol Stasiak 2019-06-26 18:31:45 +02:00
parent fae64c52a1
commit c580ba33ea
3 changed files with 13 additions and 2 deletions

View File

@ -74,6 +74,8 @@
* Fixed `#pragma` not respecting `#if`.
* Fixed nested `#if`s.
* Fixed `@long` and `@long_be` array filters.
* Fixed for-each loops with non-constant arrays.

View File

@ -119,7 +119,7 @@ object Preprocessor {
enabled = false
} else {
val value = evalParam(param, pos)
enabled = value != 0
enabled = i.enabledBefore && value != 0
ifStack.push(ifStack.pop().copy(hadEnabled = enabled))
}
}
@ -132,7 +132,7 @@ object Preprocessor {
if (i.hadEnabled) {
enabled = false
} else {
enabled = !enabled
enabled = i.enabledBefore && !enabled
}
ifStack.push(ifStack.pop().copy(hadEnabled = true, hadElse = true))
}

View File

@ -229,6 +229,15 @@ class BasicSymonTest extends FunSuite with Matchers {
| #error A should be defined
| #endif
|
| #if 0
| #error inside if 0
| #if 0
| #error inside second if 0
| #else
| #error really shouldn't happen
| #endif
| #endif
|
| #if 1 + 1 == 2
| #info 1
| #if 1 == 3