Improve error message on const int*

This commit is contained in:
Christoffer Lerno
2026-02-06 02:00:26 +01:00
parent 5c158e481b
commit 124efb2684
2 changed files with 9 additions and 0 deletions

View File

@@ -1832,6 +1832,12 @@ CHECK_ELLIPSIS:
span = c->prev_span; span = c->prev_span;
param_kind = VARDECL_PARAM; param_kind = VARDECL_PARAM;
break; break;
case TOKEN_CONST:
if (token_is_any_type(peek(c)))
{
RETURN_PRINT_ERROR_HERE("'const' is not allowed here, did you try to make a C style const parameter? In that case, consider using contracts with '@param [in]' for the parameter.");
}
FALLTHROUGH;
default: default:
if (token_is_keyword(c->tok)) if (token_is_keyword(c->tok))
{ {

View File

@@ -0,0 +1,3 @@
import std;
fn int bar(const int* baz) // #error: 'const' is not allowed here, did you try to make a C style const parameter?
{}