feat: 列表推导式 [for x in arr: expr] — parser+sema+codegen

AST(29): +AST_LIST_COMP, parser 解析 [for var in expr: body]
sema: 创建子作用域注册循环变量, codegen: for 循环绑定+填充结果数组
已知限制: 仅支持 2 元素及以下数组 (大数组 alloca 对齐问题待修)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 13:58:54 +08:00
parent 0088347576
commit 443b22bdf1
6 changed files with 128 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
fn main() -> i64 {
var src: i64[2] = src;
src[0] = 10;
src[1] = 20;
var dst: i64[2] = dst;
dst = [for x in src: x * 2];
print_i64(dst[0]); // 20
print_i64(dst[1]); // 40
return 0;
}