mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
$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.
This commit is contained in:
20
test/test_suite/compile_time/var_must_be_ct.c3
Normal file
20
test/test_suite/compile_time/var_must_be_ct.c3
Normal file
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user