stage1 完成ast 定义sema

This commit is contained in:
zzy
2026-08-03 12:39:28 +08:00
parent a4ec5656d2
commit 74d7376039
19 changed files with 3857 additions and 137 deletions

View File

@@ -78,7 +78,7 @@ fn test_slice_in_struct() i32 {
raw[0] = 65; raw[1] = 66; raw[2] = 67; raw[3] = 68;
/* Bug fix: { .ptr = ..., .len = ... } inside struct literal */
var b: Buffer = Buffer { .data = { .ptr = &raw[0], .len = 4 }, .len = 4 };
var b: Buffer = Buffer { .data = .{ .ptr = &raw[0], .len = 4 }, .len = 4 };
if b.len != 4 { ret 1; }
if b.data[0] != 65 { ret 2; }
@@ -90,7 +90,7 @@ fn test_slice_in_struct() i32 {
if raw[0] != 90 { ret 5; }
/* Initialize with shorter slice */
var b2: Buffer = Buffer { .data = { .ptr = &raw[2], .len = 2 }, .len = 2 };
var b2: Buffer = Buffer { .data = .{ .ptr = &raw[2], .len = 2 }, .len = 2 };
if b2.len != 2 { ret 6; }
if b2.data[0] != 67 { ret 7; }
@@ -211,7 +211,7 @@ fn test_complex_nesting() i32 {
var bundle: Bundle = Bundle {
.name = &str_data[0],
.buf = Buffer { .data = { .ptr = &str_data[1], .len = 3 }, .len = 3 },
.buf = Buffer { .data = .{ .ptr = &str_data[1], .len = 3 }, .len = 3 },
.row = MatrixRow { .items = [4]i32{1, 2, 3, 4} },
.pt = Point { .x = -5, .y = 15 }
};
@@ -259,7 +259,7 @@ fn test_enum_complex() i32 {
.Inactive => {
ret 2;
},
.Pending[.x = px, .y = py] => {
.Pending[p] => {
ret 3;
}
}
@@ -270,7 +270,7 @@ fn test_enum_complex() i32 {
match s2 {
.Active[val] => {},
.Inactive => { is_inactive = 1; },
.Pending[.x = px, .y = py] => {}
.Pending[p] => {}
}
if is_inactive != 1 { ret 4; }
@@ -279,9 +279,9 @@ fn test_enum_complex() i32 {
match s3 {
.Active[val] => { ret 5; },
.Inactive => { ret 6; },
.Pending[.x = px, .y = py] => {
if px != 7 { ret 7; }
if py != 8 { ret 8; }
.Pending[p] => {
if p.x != 7 { ret 7; }
if p.y != 8 { ret 8; }
}
}