feat: tuple syntax cutover — Tuple(...) type + .(...) value

Replace the bare-paren tuple grammar with explicit, position-unambiguous
forms, mirroring how structs work:

  type     `(A, B)`        -> `Tuple(A, B)`          (named keeps `:`)
  value    `(a, b)`        -> `.(a, b)`              (named uses `=`)
  typed    (new)           -> `Tuple(A, B).(a, b)`   (like `Point.{...}`)
  failable `-> (T, !)`     -> `-> T !`
           `-> (T1, T2, !)`-> `-> Tuple(T1, T2) !`   (channel outside Tuple)

Bare `(...)` is now grouping only, everywhere; a comma in bare parens is a
hard error with a migration hint. Grouping, function types `(A, B) -> R`,
param lists, lambdas, and match bindings are unaffected.

`Tuple(...)` is strictly a TYPE in every position (including `size_of` /
`type_info` args); a tuple VALUE comes only from `.(...)` (anonymous) or
`Tuple(...).(...)` (explicitly typed). A bare `Tuple(1, 2)` is a tuple
type with non-type elements -> rejected.

The ~110 tuple-bearing corpus files were migrated with a one-shot
AST-aware migrator (the `sx migrate` tool from the prior commit, removed
here). New examples: 0130 (new syntax), 0131 (typed construction), 1060
(named-tuple failable return). 1116 golden updated for the new hint text.
This commit is contained in:
agra
2026-06-25 17:53:57 +03:00
parent c882c6c63e
commit 989e18b760
124 changed files with 941 additions and 1236 deletions

View File

@@ -461,7 +461,7 @@ SqliteStmt :: struct {
// ── execution ──
// SQLITE_ROW / SQLITE_DONE on success; anything else raises with the
// detail left in the connection's errmsg.
step :: (self: *SqliteStmt) -> (i32, !SqliteErr) {
step :: (self: *SqliteStmt) -> i32 !SqliteErr {
rc := sqlite3_step(self.handle);
if rc != SQLITE_ROW and rc != SQLITE_DONE { raise error.Step; }
return rc;
@@ -564,7 +564,7 @@ ColumnMeta :: struct {
Sqlite :: struct {
handle: usize;
open :: (path: string) -> (Sqlite, !SqliteErr) {
open :: (path: string) -> Sqlite !SqliteErr {
h : usize = 0;
rc := sqlite3_open(to_cstring(path), @h);
if rc != SQLITE_OK {
@@ -574,7 +574,7 @@ Sqlite :: struct {
return Sqlite.{ handle = h };
}
open_v2 :: (path: string, flags: i32) -> (Sqlite, !SqliteErr) {
open_v2 :: (path: string, flags: i32) -> Sqlite !SqliteErr {
h : usize = 0;
rc := sqlite3_open_v2(to_cstring(path), @h, flags, 0);
if rc != SQLITE_OK {
@@ -603,7 +603,7 @@ Sqlite :: struct {
return;
}
prepare :: (self: *Sqlite, sql: string) -> (SqliteStmt, !SqliteErr) {
prepare :: (self: *Sqlite, sql: string) -> SqliteStmt !SqliteErr {
sh : usize = 0;
rc := sqlite3_prepare_v2(self.handle, sql.ptr, xx sql.len, @sh, 0);
if rc != SQLITE_OK { raise error.Prepare; }
@@ -611,7 +611,7 @@ Sqlite :: struct {
}
// prepare with SQLITE_PREPARE_* flags (e.g. PERSISTENT for the
// statement cache a storage layer keeps hot).
prepare_v3 :: (self: *Sqlite, sql: string, flags: u32) -> (SqliteStmt, !SqliteErr) {
prepare_v3 :: (self: *Sqlite, sql: string, flags: u32) -> SqliteStmt !SqliteErr {
sh : usize = 0;
rc := sqlite3_prepare_v3(self.handle, sql.ptr, xx sql.len, flags, @sh, 0);
if rc != SQLITE_OK { raise error.Prepare; }
@@ -685,7 +685,7 @@ Sqlite :: struct {
}
// Schema introspection for one column of "main".`table`.
table_column_metadata :: (self: *Sqlite, table: string, column: string) -> (ColumnMeta, !SqliteErr) {
table_column_metadata :: (self: *Sqlite, table: string, column: string) -> ColumnMeta !SqliteErr {
dt : usize = 0;
cs : usize = 0;
nn : i32 = 0;
@@ -703,7 +703,7 @@ Sqlite :: struct {
// ── serialization ──
// The whole "main" database as bytes (a valid database image).
serialize :: (self: *Sqlite) -> (string, !SqliteErr) {
serialize :: (self: *Sqlite) -> string !SqliteErr {
size : i64 = 0;
p := sqlite3_serialize(self.handle, to_cstring("main"), @size, 0);
if p == null { raise error.Serialize; }
@@ -734,7 +734,7 @@ Sqlite :: struct {
SqliteBlob :: struct {
handle: usize;
open :: (db: *Sqlite, table: string, column: string, rowid: i64, writable: bool) -> (SqliteBlob, !SqliteErr) {
open :: (db: *Sqlite, table: string, column: string, rowid: i64, writable: bool) -> SqliteBlob !SqliteErr {
h : usize = 0;
rc := sqlite3_blob_open(db.handle, to_cstring("main"), to_cstring(table), to_cstring(column),
rowid, if writable then 1 else 0, @h);
@@ -751,7 +751,7 @@ SqliteBlob :: struct {
bytes :: (self: *SqliteBlob) -> i32 {
return sqlite3_blob_bytes(self.handle);
}
read :: (self: *SqliteBlob, offset: i32, n: i32) -> (string, !SqliteErr) {
read :: (self: *SqliteBlob, offset: i32, n: i32) -> string !SqliteErr {
len : i64 = n;
raw : [*]u8 = xx context.allocator.alloc_bytes(len + 1);
rc := sqlite3_blob_read(self.handle, raw, n, offset);
@@ -778,7 +778,7 @@ SqliteBlob :: struct {
SqliteBackup :: struct {
handle: usize;
init :: (dst: *Sqlite, src: *Sqlite) -> (SqliteBackup, !SqliteErr) {
init :: (dst: *Sqlite, src: *Sqlite) -> SqliteBackup !SqliteErr {
h := sqlite3_backup_init(dst.handle, to_cstring("main"), src.handle, to_cstring("main"));
if h == 0 { raise error.Backup; }
return SqliteBackup.{ handle = h };