mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Assert on optional-returning-function in a comma expression. #2722
This commit is contained in:
8
test/test_suite/errors/discard_in_cond_valid.c3t
Normal file
8
test/test_suite/errors/discard_in_cond_valid.c3t
Normal file
@@ -0,0 +1,8 @@
|
||||
module main;
|
||||
|
||||
fn int? may_fault() @maydiscard => 2;
|
||||
|
||||
fn void main()
|
||||
{
|
||||
if (may_fault(), true);
|
||||
}
|
||||
8
test/test_suite/errors/optional_discard_in_cond.c3
Normal file
8
test/test_suite/errors/optional_discard_in_cond.c3
Normal 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
|
||||
}
|
||||
@@ -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++; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user