Macros with trailing bodys aren't allowed as the single statement after a while loop with no body #1772.

This commit is contained in:
Christoffer Lerno
2025-01-05 16:00:39 +01:00
parent c6c7baa3b4
commit ab2d223e71
3 changed files with 40 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
import std;
fn void loop_start() => io::printn("Loop Start");
fn void loop_end() => io::printn("Loop End");
fn void do_something() => io::printn("Do something");
macro @thing(; @body())
{
loop_start();
@body();
loop_end();
}
fn void strcpy(char *s1, char *s2) {
while (*s1++ = *s2++);
}
fn void main()
{
while (true) @thing()
{
do_something();
break;
};
for (;;) @thing()
{
do_something();
break;
};
if (true) @thing()
{
do_something();
};
}