Files
c3c/test/test_suite/compile_time/var_must_be_ct.c3
Christoffer Lerno 988549599d $is_const is deprecated in favour of @is_const based on $defined.
`$foo` variables could be assigned non-compile time values.
`$foo[0] = ...` was incorrectly requiring that the assigned values were compile time constants.
2025-07-10 18:31:44 +02:00

21 lines
301 B
Plaintext

fn void test1()
{
int a;
var $x;
$x = a; // #error: only assign constants to a compile time
}
fn void test2()
{
int a;
int[2] $x = { 1, 2 };
$x[0] = a; // #error: argument must be a constant value
}
int g;
fn void test3()
{
int*[2] $x = { &g + 1, null };
int* $y = &g + 1;
$x[0] = &g + 1;
}