Fixed regression with optional argument macros and lambdas.

This commit is contained in:
Christoffer Lerno
2025-08-30 01:00:24 +02:00
parent de8aed9d96
commit 10bc68fb39
2 changed files with 28 additions and 4 deletions

View File

@@ -0,0 +1,23 @@
module lambda;
macro @test(int $xd = ...)
{
return fn int() {
static int tx = 0;
$if $defined($xd):
return $xd + tx++;
$else
return 0;
$endif
};
}
fn void test_lambda_in_macro() @test
{
assert(@test(2)() == 2);
assert(@test(2)() == 3);
assert(@test(2)() == 4);
assert(@test(2)() == 5);
assert(@test(4)() == 4);
assert(@test()() == 0);
}