Improved errors on optional return. Fixes to @nodiscard erroring. Addresses #1062

This commit is contained in:
Christoffer Lerno
2023-11-03 23:50:15 +01:00
parent 5dedaa8e67
commit 69470b8738
6 changed files with 50 additions and 9 deletions

View 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!'
}

View File

@@ -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()

View File

@@ -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()