Open
Description
Nim version 0.17.2 (from commit 811fbda)
That's quite unusual issue, but I caught it today in our project.
Here's the sample code:
proc f(): int32 =
{.emit: """
#if 1
`result` = 1;
#endif
""".}
echo f()
The important part here is that code inside emit
begins with a C preprocessor directive. If you compile this code with command
nim c --lineDir:on test.nim
compiler produces following C code:
N_NIMCALL(NI32, f_nihCtddZTotXPkpuYzTLdQ)(void) {
NI32 result; nimfr_("f", "test.nim"); result = (NI32)0;
#line 3 "C:\\projects\\temp\\test.nim"
nimln_(3, "test.nim"); #if 1
result = 1;
#endif
popFrame(); return result;}
As you can see, first line break before #if 1
is somehow removed and #if 1
goes to the same line as nimln_
. Well, and this code doesn't compile since preprocessor directives should start with a new line.