trailing commas
This commit is contained in:
@@ -3120,5 +3120,31 @@ END;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Trailing commas ──────────────────────────────────────────
|
||||
print("=== Trailing Commas ===\n");
|
||||
{
|
||||
// Struct literal with trailing comma
|
||||
Vec4 :: struct { x: f64; y: f64; z: f64; w: f64; }
|
||||
v := Vec4.{
|
||||
x = 1.0,
|
||||
y = 2.0,
|
||||
z = 3.0,
|
||||
w = 4.0,
|
||||
};
|
||||
assert(v.x == 1.0);
|
||||
assert(v.w == 4.0);
|
||||
|
||||
// Function call with trailing comma
|
||||
add :: (a: s64, b: s64) -> s64 { return a + b; }
|
||||
r := add(10, 20,);
|
||||
assert(r == 30);
|
||||
|
||||
// Array literal with trailing comma
|
||||
arr := s64.[1, 2, 3,];
|
||||
assert(arr[2] == 3);
|
||||
|
||||
print("trailing commas ok\n");
|
||||
}
|
||||
|
||||
print("=== DONE ===\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user