ITADN
c3lang/c3c/Issues

$eval is not evaluated in variable declaration

#3323OpenBen0981 创建于 2026-06-12
B
Ben0981commented
### The Problem When trying to create a variable at compile time like so : ```c $VarType $eval($varName) = $val; ``` The following error is thrown by the compiler: ``` $VarType $eval($varName) = $val; ^^^^^ Error: A variable name was expected. ``` If the variable was already declared an assignment using `$eval` is however possible. ```c var $varName = "test"; int test; $eval($varName) = $val; ``` ### Minimal Example: ```c fn void run() { @foo(5); } macro @foo($val) { var $VarType = int; var $varName = "test"; $VarType $eval($varName) = $val; } ``` ### Expected Behaviour The compiler should evaluate a valid expression in place of an identifier in a variable declaration in the same way it does for an assignment operation to make it possible to declare variables at compile time. #### Compiler Version: C3 Compiler Version: 0.8.2 (Pre-release, Jun 12 2026 20:15:43) Git Hash: 303dd2230308420098f0f8d6601ba7d02338e2c8 Backends: LLVM LLVM version: 22.1.8 LLVM default target: x86_64-unknown-linux-gnu
2 条评论