mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Improved errors on optional return. Fixes to @nodiscard erroring. Addresses #1062
This commit is contained in:
15
test/test_suite/errors/more_optional_discard.c3
Normal file
15
test/test_suite/errors/more_optional_discard.c3
Normal file
@@ -0,0 +1,15 @@
|
||||
module abc;
|
||||
|
||||
macro int mtest1(int a) @nodiscard { return 0; }
|
||||
macro int! mtest2(int a) { return 0; }
|
||||
fn int ftest1(int a) @nodiscard { return 0; }
|
||||
fn int! ftest2(int a) { return 0; }
|
||||
|
||||
|
||||
fn void main()
|
||||
{
|
||||
mtest1(3); // #error: The called macro is marked `@nodiscard`
|
||||
mtest2(3); // #error: The macro returns 'int!', which is an optional
|
||||
ftest1(3); // #error: The called function is marked `@nodiscard`
|
||||
ftest2(3); // #error: The function returns 'int!'
|
||||
}
|
||||
@@ -37,14 +37,14 @@ fn void test5()
|
||||
{
|
||||
int! x;
|
||||
int y;
|
||||
def3(y); // #error: The result of the function must be used
|
||||
def3(y); // #error: The function returns 'int!'
|
||||
}
|
||||
|
||||
fn void test6()
|
||||
{
|
||||
int! x;
|
||||
int y;
|
||||
def3(x); // #error: The result of the function must be used
|
||||
def3(x); // #error: The function returns 'int!'
|
||||
}
|
||||
|
||||
fn void test7()
|
||||
|
||||
@@ -37,14 +37,14 @@ fn void test5()
|
||||
{
|
||||
int! x;
|
||||
int y;
|
||||
def3(y); // #error: The result of the macro must
|
||||
def3(y); // #error: The macro returns 'int!'
|
||||
}
|
||||
|
||||
fn void test6()
|
||||
{
|
||||
int! x;
|
||||
int y;
|
||||
def3(x); // #error: The result of the macro must
|
||||
def3(x); // #error: The macro returns 'int!'
|
||||
}
|
||||
|
||||
fn void test7()
|
||||
|
||||
Reference in New Issue
Block a user