- Assert on optional-returning-function in a comma expression. #2722

This commit is contained in:
Christoffer Lerno
2026-01-07 15:53:54 +01:00
parent 197f82d829
commit 0fc1871ddf
7 changed files with 26 additions and 4 deletions

View File

@@ -0,0 +1,8 @@
module main;
fn int? may_fault() @maydiscard => 2;
fn void main()
{
if (may_fault(), true);
}

View File

@@ -0,0 +1,8 @@
module main;
fn int? may_fault() => 2;
fn void main()
{
if (may_fault(), true); // #error: You can either assign it to a variable
}

View File

@@ -59,7 +59,7 @@ fn void test8()
{
int? a;
int e;
if (e == 0, try c = a && try d = a && e > 0) {}
if (e = 3, try c = a && try d = a && e > 0) {}
if (try b = a && try c = a && e > 0) {}
if (try c = a && try d = a) { c++; }
}