Closed iAndyHD3 closed 6 months ago
It appears that code inside of false evaluated
#if
conditions is skipped, as such this code does not produce any errors#if TEST ksdfj jkkfjlkas #endif
This is expected. Code under a false condition is not parsed. Same as with C, C++ and C# compilers.
Why?
class Foo {
#if INTERNAL
internal
#endif
#if PROTECTED
protected
#endif
int Bar;
}
However, this valid code dos not compile if
TEST
is not defined, which means code is not being skipped correctly? IfTEST
is defined, it compiles as expected#if TEST class Test { public static void Main() { int a = 0; Console.WriteLine($"{a}"); //Test.fu(7): ERROR: Unterminated string literal } } #endif
This is a bug. Interpolated strings need a cooperation between the parser and the lexer and the parser is disabled for false conditions.
Another error that isn't being skipped correctly: (
TEST
is not defined)#if TEST 0a //Test.fu(2): ERROR: Invalid integer #endif
This is expected. Code under a false condition must be a valid token sequence as it gets lexed.
Why?
There might be a /*
opening a multi-line comment which comments-out the #endif
. But we can't just search for /*
characters because they might be in a string literal ("/*"
) or a single-line comment (// /*
).
Unrelated: If I have a few small suggestions and questions, should I post them in Discussions?
If you have specific bug reports or feature requests, post them in Issues. For generic discussion and questions, use Discussions.
It appears that code inside of false evaluated
#if
conditions is skipped, as such this code does not produce any errorsHowever, this valid code dos not compile if
TEST
is not defined, which means code is not being skipped correctly? IfTEST
is defined, it compiles as expectedAnother error that isn't being skipped correctly: (
TEST
is not defined)Unrelated: If I have a few small suggestions and questions, should I post them in Discussions?