From 959845bd3043a0335840322f31c2a9bf7bc82ea3 Mon Sep 17 00:00:00 2001 From: agra Date: Sun, 28 Jun 2026 16:38:23 +0300 Subject: [PATCH] style: migrate arrow-block lambdas `() => { .. }` to `() { .. }` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The canonical sx block-body lambda is `(params) { stmts }` (and `(params) -> Ret { stmts }`); the arrow form `=>` is for EXPRESSION bodies (`(params) => expr`). The arrow-block hybrid `(params) => { .. }` was being used in 33 files — convert all of them by dropping the `=>`. The two forms are exactly equivalent (verified: identical IR and identical runtime values — the block tail is the value with or without a `-> Ret`), so this is a pure source cleanup: no `.ir` churn, and the only snapshot change is 0923's diagnostic COLUMN (a negative narrowing test whose error span shifted by the removed `=> `). Arrow EXPRESSION bodies (`=> expr`, `=> .{..}`, `=> [..]`) and `=>` inside comments/strings were left untouched. Migrated across examples/concurrency, examples/{closures,ffi-objc,generics,optionals,types}, issues/, and the stdlib (io.sx, sched.sx). Suite 855/0. --- .../0304-closures-enum-arg-through-closure-field.sx | 2 +- .../0305-closures-closure-field-call-via-self-ptr.sx | 2 +- .../0312-closure-optional-param-arg-coercion.sx | 2 +- .../closures/0314-closures-capture-failable-call.sx | 12 ++++++------ examples/closures/0315-closures-struct-field-call.sx | 2 +- .../concurrency/1811-concurrency-fiber-scheduler.sx | 2 +- .../1812-concurrency-fiber-suspend-wake.sx | 4 ++-- .../1813-concurrency-fiber-async-suspend.sx | 6 +++--- .../concurrency/1814-concurrency-fiber-sim-timer.sx | 10 +++++----- .../1815-concurrency-fiber-timer-early-wake.sx | 4 ++-- .../concurrency/1816-concurrency-fiber-io-pipe.sx | 4 ++-- .../1817-concurrency-fiber-m1-end-to-end.sx | 8 ++++---- .../1818-concurrency-fiber-sleep-negative.sx | 2 +- .../1819-concurrency-fiber-double-wait.sx | 4 ++-- .../1820-concurrency-fiber-scheduler-deinit.sx | 6 +++--- examples/concurrency/1821-concurrency-fiber-race.sx | 8 ++++---- .../1822-concurrency-fiber-context-inherit.sx | 2 +- .../1824-concurrency-fiber-async-await.sx | 6 +++--- .../1825-concurrency-fiber-cancel-suspend.sx | 4 ++-- .../1826-concurrency-fiber-race-failing-loser.sx | 6 +++--- .../1827-concurrency-fiber-async-leak-reclaimed.sx | 8 ++++---- examples/ffi-objc/1302-ffi-objc-block-noop.sx | 2 +- examples/ffi-objc/1303-ffi-objc-block-capture.sx | 2 +- examples/ffi-objc/1304-ffi-objc-block-multi-arg.sx | 2 +- examples/ffi-objc/1305-ffi-objc-block-inline.sx | 2 +- .../ffi-objc/1324-ffi-objc-arc-01-autoreleasepool.sx | 2 +- .../generics/0206-generics-generic-into-block.sx | 2 +- .../0923-optionals-narrowing-no-closure-leak.sx | 2 +- .../0923-optionals-narrowing-no-closure-leak.stderr | 6 +++--- examples/types/0117-types-block-string-arg.sx | 2 +- examples/types/0216-types-multi-return-closure.sx | 6 +++--- issues/0156-comptime-pack-captured-into-closure.sx | 2 +- library/modules/ffi/objc.sx | 2 +- library/modules/std/io.sx | 6 +++--- library/modules/std/sched.sx | 2 +- 35 files changed, 72 insertions(+), 72 deletions(-) diff --git a/examples/closures/0304-closures-enum-arg-through-closure-field.sx b/examples/closures/0304-closures-enum-arg-through-closure-field.sx index badf6618..0d875d14 100644 --- a/examples/closures/0304-closures-enum-arg-through-closure-field.sx +++ b/examples/closures/0304-closures-enum-arg-through-closure-field.sx @@ -10,7 +10,7 @@ Ctx :: struct { } main :: () -> i32 { - c : Ctx = .{ on = (f: Fmt) => { + c : Ctx = .{ on = (f: Fmt) { n : i64 = xx f; print("cl f = {}\n", n); }}; diff --git a/examples/closures/0305-closures-closure-field-call-via-self-ptr.sx b/examples/closures/0305-closures-closure-field-call-via-self-ptr.sx index 905ad557..458db060 100644 --- a/examples/closures/0305-closures-closure-field-call-via-self-ptr.sx +++ b/examples/closures/0305-closures-closure-field-call-via-self-ptr.sx @@ -31,7 +31,7 @@ ticks : i32 = 0; main :: () -> i32 { h : Holder = .{}; - h.set(() => { ticks += 1; }); + h.set(() { ticks += 1; }); h.call_direct(); h.call_hoisted(); diff --git a/examples/closures/0312-closure-optional-param-arg-coercion.sx b/examples/closures/0312-closure-optional-param-arg-coercion.sx index 83da0319..d5110e77 100644 --- a/examples/closures/0312-closure-optional-param-arg-coercion.sx +++ b/examples/closures/0312-closure-optional-param-arg-coercion.sx @@ -11,7 +11,7 @@ #import "modules/std.sx"; main :: () { - pick := (p: ?i64) -> i64 => { + pick := (p: ?i64) -> i64 { if p == null { return -1; } return p; // narrowed inside the lambda body }; diff --git a/examples/closures/0314-closures-capture-failable-call.sx b/examples/closures/0314-closures-capture-failable-call.sx index 48a4f81d..70edd20d 100644 --- a/examples/closures/0314-closures-capture-failable-call.sx +++ b/examples/closures/0314-closures-capture-failable-call.sx @@ -6,7 +6,7 @@ // the call types as `unresolved` (so `catch`/`try` reject it). // // Regression (PLAN-IO-UNIFY Phase 3 blocker): the async completion closure -// `() => { f.value = worker() catch {…} }` captures a `Closure() -> ($R, !)` +// `() { f.value = worker() catch {…} }` captures a `Closure() -> ($R, !)` // worker and consumes its error channel — exactly this shape. #import "modules/std.sx"; @@ -15,7 +15,7 @@ Box :: struct { run: Closure() -> void; } // `catch` path: the nested closure absorbs the worker's error. run_catch :: (worker: Closure() -> (i64, !)) { b : Box = ---; - b.run = () => { + b.run = () { v := worker() catch { print("caught\n"); return; @@ -27,17 +27,17 @@ run_catch :: (worker: Closure() -> (i64, !)) { // `try` path: the nested closure is itself failable and propagates. mk_trier :: (worker: Closure() -> (i64, !)) -> Closure() -> (i64, !) { - return () -> (i64, !) => { + return () -> (i64, !) { v := try worker(); v + 100 }; } main :: () -> i64 { - run_catch(() -> (i64, !) => { 7 }); // ok 7 - run_catch(() -> (i64, !) => { raise error.Bad; }); // caught + run_catch(() -> (i64, !) { 7 }); // ok 7 + run_catch(() -> (i64, !) { raise error.Bad; }); // caught - t := mk_trier(() -> (i64, !) => { 5 }); + t := mk_trier(() -> (i64, !) { 5 }); r := t() catch { return 1; }; print("try {}\n", r); // try 105 return 0; diff --git a/examples/closures/0315-closures-struct-field-call.sx b/examples/closures/0315-closures-struct-field-call.sx index 5a803b97..d1e04b3a 100644 --- a/examples/closures/0315-closures-struct-field-call.sx +++ b/examples/closures/0315-closures-struct-field-call.sx @@ -28,7 +28,7 @@ main :: () -> i64 { b : CB = ---; b.add = (x: i64, y: i64) => x + y; b.fp = triple; - b.work = (n: i64) -> (i64, !) => { + b.work = (n: i64) -> (i64, !) { if n < 0 { raise error.Negative; } n * 10 }; diff --git a/examples/concurrency/1811-concurrency-fiber-scheduler.sx b/examples/concurrency/1811-concurrency-fiber-scheduler.sx index 9597e89d..4035ea0a 100644 --- a/examples/concurrency/1811-concurrency-fiber-scheduler.sx +++ b/examples/concurrency/1811-concurrency-fiber-scheduler.sx @@ -46,7 +46,7 @@ main :: () -> i64 { // Three DIFFERENT fiber bodies (distinct captured ids), interleaving via // yield_now. Each appends its id once per round for 3 rounds. spawn_worker :: (ps: *sched.Scheduler, psh: *Shared, my_id: i64) { - ps.spawn(() => { + ps.spawn(() { r := 0; while r < 3 { append(psh, my_id); diff --git a/examples/concurrency/1812-concurrency-fiber-suspend-wake.sx b/examples/concurrency/1812-concurrency-fiber-suspend-wake.sx index a521d56e..cb4bc937 100644 --- a/examples/concurrency/1812-concurrency-fiber-suspend-wake.sx +++ b/examples/concurrency/1812-concurrency-fiber-suspend-wake.sx @@ -36,7 +36,7 @@ main :: () -> i64 { // Fiber A: record 10, park, then (after wake) record 11. Store A's handle in // the shared state so B can wake it. mk_a :: (ps: *sched.Scheduler, psh: *Sh) { - psh.parked = ps.spawn(() => { + psh.parked = ps.spawn(() { rec(psh, 10); ps.suspend_self(); rec(psh, 11); @@ -45,7 +45,7 @@ main :: () -> i64 { // Fiber B: record 20, wake A (legit) + a spurious second wake (safe no-op), // record 21. mk_b :: (ps: *sched.Scheduler, psh: *Sh) { - ps.spawn(() => { + ps.spawn(() { rec(psh, 20); ps.wake(psh.parked); // legitimate: A is parked ps.wake(psh.parked); // spurious: A is now .ready/queued — must no-op diff --git a/examples/concurrency/1813-concurrency-fiber-async-suspend.sx b/examples/concurrency/1813-concurrency-fiber-async-suspend.sx index 0242afc8..711cce23 100644 --- a/examples/concurrency/1813-concurrency-fiber-async-suspend.sx +++ b/examples/concurrency/1813-concurrency-fiber-async-suspend.sx @@ -43,16 +43,16 @@ main :: () -> i64 { // cancel. It runs as a fiber so `await` has a `self.current` to park. The // scheduler is installed as `context.io`, so the unified async layer reaches it. push .{ io = xx s } { - ps.spawn(() => { + ps.spawn(() { // Worker A yields mid-body so B interleaves before A completes. - a := context.io.async(() -> (i64, !) => { + a := context.io.async(() -> (i64, !) { rec(pl, 1); ps.yield_now(); // suspend A; B (already spawned) runs to completion rec(pl, 3); 42 }); // Worker B runs straight through (no yield). - b := context.io.async(() -> (i64, !) => { + b := context.io.async(() -> (i64, !) { rec(pl, 2); 100 }); diff --git a/examples/concurrency/1814-concurrency-fiber-sim-timer.sx b/examples/concurrency/1814-concurrency-fiber-sim-timer.sx index d44d6c85..e6c62ae9 100644 --- a/examples/concurrency/1814-concurrency-fiber-sim-timer.sx +++ b/examples/concurrency/1814-concurrency-fiber-sim-timer.sx @@ -50,12 +50,12 @@ main :: () -> i64 { pl := @lg; // Spawn order A, B, C, D, E — but the WAKE order is set by deadline. - ps.spawn(() => { ps.sleep(30); rec(pl, 1, ps.now_ms()); }); // A: latest - ps.spawn(() => { ps.sleep(10); rec(pl, 2, ps.now_ms()); }); // B: earliest - ps.spawn(() => { ps.sleep(20); rec(pl, 3, ps.now_ms()); }); // C: middle + ps.spawn(() { ps.sleep(30); rec(pl, 1, ps.now_ms()); }); // A: latest + ps.spawn(() { ps.sleep(10); rec(pl, 2, ps.now_ms()); }); // B: earliest + ps.spawn(() { ps.sleep(20); rec(pl, 3, ps.now_ms()); }); // C: middle // Same-deadline FIFO pair: D before E, both at t=15 → wake D then E. - ps.spawn(() => { ps.sleep(15); rec(pl, 4, ps.now_ms()); }); // D - ps.spawn(() => { ps.sleep(15); rec(pl, 5, ps.now_ms()); }); // E + ps.spawn(() { ps.sleep(15); rec(pl, 4, ps.now_ms()); }); // D + ps.spawn(() { ps.sleep(15); rec(pl, 5, ps.now_ms()); }); // E s.run(); diff --git a/examples/concurrency/1815-concurrency-fiber-timer-early-wake.sx b/examples/concurrency/1815-concurrency-fiber-timer-early-wake.sx index d279c0ae..38c1c226 100644 --- a/examples/concurrency/1815-concurrency-fiber-timer-early-wake.sx +++ b/examples/concurrency/1815-concurrency-fiber-timer-early-wake.sx @@ -29,11 +29,11 @@ main :: () -> i64 { // Sleeper: arm sleep(100), park; when woken (early), record 1 and finish. mk_sleeper :: (ps: *sched.Scheduler, pst: *S) { - pst.sleeper = ps.spawn(() => { ps.sleep(100); rec(pst, 1); }); + pst.sleeper = ps.spawn(() { ps.sleep(100); rec(pst, 1); }); } // Waker: record 2, then wake the sleeper BEFORE its 100ms timer fires. mk_waker :: (ps: *sched.Scheduler, pst: *S) { - ps.spawn(() => { rec(pst, 2); ps.wake(pst.sleeper); }); + ps.spawn(() { rec(pst, 2); ps.wake(pst.sleeper); }); } mk_sleeper(ps, pst); mk_waker(ps, pst); diff --git a/examples/concurrency/1816-concurrency-fiber-io-pipe.sx b/examples/concurrency/1816-concurrency-fiber-io-pipe.sx index 16bc7656..f7a90a74 100644 --- a/examples/concurrency/1816-concurrency-fiber-io-pipe.sx +++ b/examples/concurrency/1816-concurrency-fiber-io-pipe.sx @@ -56,7 +56,7 @@ main :: () -> i64 { // Reader: block on the (empty) pipe until it is readable, then read 3 bytes. mk_reader :: (ps: *sched.Scheduler, pst: *S, rfd: i32) { - ps.spawn(() => { + ps.spawn(() { ps.block_on_fd(rfd, true); // parks until read_fd is readable n := read(rfd, xx @pst.bytes[0], xx 3); pst.read_n = xx n; @@ -65,7 +65,7 @@ main :: () -> i64 { } // Writer: write 3 bytes ('a','b','c') to the write end. mk_writer :: (ps: *sched.Scheduler, pst: *S, wfd: i32) { - ps.spawn(() => { + ps.spawn(() { buf : [3]u8 = ---; buf[0] = xx 97; buf[1] = xx 98; buf[2] = xx 99; // 'a' 'b' 'c' write(wfd, xx @buf[0], xx 3); diff --git a/examples/concurrency/1817-concurrency-fiber-m1-end-to-end.sx b/examples/concurrency/1817-concurrency-fiber-m1-end-to-end.sx index 236f5f3e..334e4a43 100644 --- a/examples/concurrency/1817-concurrency-fiber-m1-end-to-end.sx +++ b/examples/concurrency/1817-concurrency-fiber-m1-end-to-end.sx @@ -40,11 +40,11 @@ main :: () -> i64 { // scheduler is installed as `context.io`, so the unified async layer // (`context.io.async`/`await`/`sleep`/`now_ms`) reaches it inside the workers. push .{ io = xx s } { - ps.spawn(() => { + ps.spawn(() { // Launch three async workers; each sleeps, logs its completion, returns. - a := context.io.async(() -> (i64, !) => { try context.io.sleep(30); rec(pl, 1, context.io.now_ms()); 100 }); - b := context.io.async(() -> (i64, !) => { try context.io.sleep(10); rec(pl, 2, context.io.now_ms()); 20 }); - c := context.io.async(() -> (i64, !) => { try context.io.sleep(20); rec(pl, 3, context.io.now_ms()); 3 }); + a := context.io.async(() -> (i64, !) { try context.io.sleep(30); rec(pl, 1, context.io.now_ms()); 100 }); + b := context.io.async(() -> (i64, !) { try context.io.sleep(10); rec(pl, 2, context.io.now_ms()); 20 }); + c := context.io.async(() -> (i64, !) { try context.io.sleep(20); rec(pl, 3, context.io.now_ms()); 3 }); // Await in SPAWN order; results come back correct regardless. va := a.await() or { -1 }; diff --git a/examples/concurrency/1818-concurrency-fiber-sleep-negative.sx b/examples/concurrency/1818-concurrency-fiber-sleep-negative.sx index 7e5e89dc..bc827cb2 100644 --- a/examples/concurrency/1818-concurrency-fiber-sleep-negative.sx +++ b/examples/concurrency/1818-concurrency-fiber-sleep-negative.sx @@ -8,7 +8,7 @@ sched :: #import "modules/std/sched.sx"; main :: () -> i64 { s := sched.Scheduler.init(); ps := @s; - ps.spawn(() => { ps.sleep(10); ps.sleep(-5); }); // -5 → loud abort + ps.spawn(() { ps.sleep(10); ps.sleep(-5); }); // -5 → loud abort s.run(); print("unreachable\n"); return 0; diff --git a/examples/concurrency/1819-concurrency-fiber-double-wait.sx b/examples/concurrency/1819-concurrency-fiber-double-wait.sx index 0f98d191..2a4827a0 100644 --- a/examples/concurrency/1819-concurrency-fiber-double-wait.sx +++ b/examples/concurrency/1819-concurrency-fiber-double-wait.sx @@ -12,8 +12,8 @@ S :: struct { t: *Future(i64); } main :: () -> i64 { st : S = ---; st.t = null; s := sched.Scheduler.init(); ps := @s; pst := @st; - mkprod :: (ps: *sched.Scheduler, pst: *S) { pst.t = context.io.async(() -> (i64, !) => { ps.yield_now(); 42 }); } - mkw :: (ps: *sched.Scheduler, pst: *S) { ps.spawn(() => { x := pst.t.await() or { -1 }; print("got {}\n", x); }); } + mkprod :: (ps: *sched.Scheduler, pst: *S) { pst.t = context.io.async(() -> (i64, !) { ps.yield_now(); 42 }); } + mkw :: (ps: *sched.Scheduler, pst: *S) { ps.spawn(() { x := pst.t.await() or { -1 }; print("got {}\n", x); }); } push .{ io = xx s } { mkprod(ps, pst); mkw(ps, pst); mkw(ps, pst); // second waiter → loud abort s.run(); diff --git a/examples/concurrency/1820-concurrency-fiber-scheduler-deinit.sx b/examples/concurrency/1820-concurrency-fiber-scheduler-deinit.sx index 328bfeec..6ff8826a 100644 --- a/examples/concurrency/1820-concurrency-fiber-scheduler-deinit.sx +++ b/examples/concurrency/1820-concurrency-fiber-scheduler-deinit.sx @@ -70,11 +70,11 @@ main :: () -> i64 { ps := @s; pst := @st; // SLEEPER — arms a virtual-time timer, then parks. - ps.spawn(() => { ps.sleep(5); }); + ps.spawn(() { ps.sleep(5); }); // READER — blocks on the empty pipe until kqueue reports it readable. mk_reader :: (ps: *sched.Scheduler, pst: *S, rfd: i32) { - ps.spawn(() => { + ps.spawn(() { ps.block_on_fd(rfd, true); n := read(rfd, xx @pst.bytes[0], xx 3); pst.read_n = xx n; @@ -83,7 +83,7 @@ main :: () -> i64 { } // WRITER — writes 'a' 'b' 'c', making the pipe readable. mk_writer :: (ps: *sched.Scheduler, wfd: i32) { - ps.spawn(() => { + ps.spawn(() { buf : [3]u8 = ---; buf[0] = xx 97; buf[1] = xx 98; buf[2] = xx 99; write(wfd, xx @buf[0], xx 3); diff --git a/examples/concurrency/1821-concurrency-fiber-race.sx b/examples/concurrency/1821-concurrency-fiber-race.sx index 27da5919..c9b5247b 100644 --- a/examples/concurrency/1821-concurrency-fiber-race.sx +++ b/examples/concurrency/1821-concurrency-fiber-race.sx @@ -30,11 +30,11 @@ main :: () -> i64 { // The coordinator runs as a fiber so `race` has a `current` to park. push .{ io = xx s } { - ps.spawn(() => { + ps.spawn(() { // Three async workers, DIFFERENT result types and sleep durations. - a := context.io.async(() -> (i64, !) => { try context.io.sleep(10); rec(pl, 1, context.io.now_ms()); 111 }); - b := context.io.async(() -> (bool, !) => { try context.io.sleep(20); rec(pl, 2, context.io.now_ms()); true }); - c := context.io.async(() -> (f64, !) => { try context.io.sleep(30); rec(pl, 3, context.io.now_ms()); 2.5 }); + a := context.io.async(() -> (i64, !) { try context.io.sleep(10); rec(pl, 1, context.io.now_ms()); 111 }); + b := context.io.async(() -> (bool, !) { try context.io.sleep(20); rec(pl, 2, context.io.now_ms()); true }); + c := context.io.async(() -> (f64, !) { try context.io.sleep(30); rec(pl, 3, context.io.now_ms()); 2.5 }); // Race them. `a` (sleep 10) wins; `b` and `c` are cancelled — their // post-sleep work never runs (true cancellation). diff --git a/examples/concurrency/1822-concurrency-fiber-context-inherit.sx b/examples/concurrency/1822-concurrency-fiber-context-inherit.sx index ac69f375..3587b5c0 100644 --- a/examples/concurrency/1822-concurrency-fiber-context-inherit.sx +++ b/examples/concurrency/1822-concurrency-fiber-context-inherit.sx @@ -24,7 +24,7 @@ main :: () -> i64 { ps := @s; print("outside: marker id = {}\n", mk.id); push .{ data = xx @mk } { - ps.spawn(() => { + ps.spawn(() { m : *Marker = xx context.data; // inherited from the spawn-time context print("inside fiber: context.data marker id = {}\n", m.id); }); diff --git a/examples/concurrency/1824-concurrency-fiber-async-await.sx b/examples/concurrency/1824-concurrency-fiber-async-await.sx index 1f0fc5c6..825abcff 100644 --- a/examples/concurrency/1824-concurrency-fiber-async-await.sx +++ b/examples/concurrency/1824-concurrency-fiber-async-await.sx @@ -23,10 +23,10 @@ main :: () -> i64 { s := sched.Scheduler.init(); ps := @s; pl := @lg; push .{ io = xx s } { - ps.spawn(() => { + ps.spawn(() { rec(pl, 1); // coordinator starts - a := context.io.async(() -> (i64, !) => { rec(pl, 10); 100 }); // worker A — deferred - b := context.io.async(() -> (i64, !) => { rec(pl, 20); 23 }); // worker B — deferred + a := context.io.async(() -> (i64, !) { rec(pl, 10); 100 }); // worker A — deferred + b := context.io.async(() -> (i64, !) { rec(pl, 20); 23 }); // worker B — deferred rec(pl, 2); // both spawned, neither has run va := a.await() or { -1 }; // park; A runs, wakes us vb := b.await() or { -1 }; diff --git a/examples/concurrency/1825-concurrency-fiber-cancel-suspend.sx b/examples/concurrency/1825-concurrency-fiber-cancel-suspend.sx index 7b3a1e13..3cb3c5c1 100644 --- a/examples/concurrency/1825-concurrency-fiber-cancel-suspend.sx +++ b/examples/concurrency/1825-concurrency-fiber-cancel-suspend.sx @@ -27,8 +27,8 @@ main :: () -> i64 { s := sched.Scheduler.init(); ps := @s; pl := @lg; push .{ io = xx s } { - ps.spawn(() => { - w := context.io.async(() -> (i64, !) => { + ps.spawn(() { + w := context.io.async(() -> (i64, !) { rec(pl, 1); // worker started try context.io.sleep(10); // park; cancel delivers Canceled HERE rec(pl, 2); // POST-SUSPEND — must NEVER run diff --git a/examples/concurrency/1826-concurrency-fiber-race-failing-loser.sx b/examples/concurrency/1826-concurrency-fiber-race-failing-loser.sx index 62080af8..42e458a4 100644 --- a/examples/concurrency/1826-concurrency-fiber-race-failing-loser.sx +++ b/examples/concurrency/1826-concurrency-fiber-race-failing-loser.sx @@ -17,9 +17,9 @@ main :: () -> i64 { s := sched.Scheduler.init(); ps := @s; push .{ io = xx s } { - ps.spawn(() => { - a := context.io.async(() -> (i64, !) => { try context.io.sleep(5); raise error.Boom; }); - b := context.io.async(() -> (i64, !) => { try context.io.sleep(10); 42 }); + ps.spawn(() { + a := context.io.async(() -> (i64, !) { try context.io.sleep(5); raise error.Boom; }); + b := context.io.async(() -> (i64, !) { try context.io.sleep(10); 42 }); winner := context.io.race(.(a = a, b = b)); if winner == { case .a: (v) { print("winner: a = {}\n", v); } diff --git a/examples/concurrency/1827-concurrency-fiber-async-leak-reclaimed.sx b/examples/concurrency/1827-concurrency-fiber-async-leak-reclaimed.sx index f9f7542a..390805a3 100644 --- a/examples/concurrency/1827-concurrency-fiber-async-leak-reclaimed.sx +++ b/examples/concurrency/1827-concurrency-fiber-async-leak-reclaimed.sx @@ -28,10 +28,10 @@ main :: () -> i64 { ps := @s; pbase.* = gpa.alloc_count; // baseline: scheduler is live, no tasks yet push .{ io = xx s, allocator = xx gpa, data = null } { - ps.spawn(() => { - a := context.io.async(() -> (i64, !) => { try context.io.sleep(10); 100 }); - b := context.io.async(() -> (i64, !) => { try context.io.sleep(20); 20 }); - c := context.io.async(() -> (i64, !) => { try context.io.sleep(30); 3 }); + ps.spawn(() { + a := context.io.async(() -> (i64, !) { try context.io.sleep(10); 100 }); + b := context.io.async(() -> (i64, !) { try context.io.sleep(20); 20 }); + c := context.io.async(() -> (i64, !) { try context.io.sleep(30); 3 }); psum.* = (a.await() or 0) + (b.await() or 0) + (c.await() or 0); }); ps.run(); diff --git a/examples/ffi-objc/1302-ffi-objc-block-noop.sx b/examples/ffi-objc/1302-ffi-objc-block-noop.sx index 83dc0680..79dc192e 100644 --- a/examples/ffi-objc/1302-ffi-objc-block-noop.sx +++ b/examples/ffi-objc/1302-ffi-objc-block-noop.sx @@ -9,7 +9,7 @@ #import "modules/ffi/objc_block.sx"; main :: () -> i32 { - cl := () => { print("noop block ran\n"); }; + cl := () { print("noop block ran\n"); }; b : Block = xx cl; invoke_fn : (*Block) -> void abi(.c) = xx b.invoke; invoke_fn(@b); diff --git a/examples/ffi-objc/1303-ffi-objc-block-capture.sx b/examples/ffi-objc/1303-ffi-objc-block-capture.sx index 5079c7f6..0d057e22 100644 --- a/examples/ffi-objc/1303-ffi-objc-block-capture.sx +++ b/examples/ffi-objc/1303-ffi-objc-block-capture.sx @@ -9,7 +9,7 @@ main :: () -> i32 { x : i64 = 42; y : i64 = 100; - cl := () => { print("x + y = {}\n", x + y); }; + cl := () { print("x + y = {}\n", x + y); }; b : Block = xx cl; invoke_fn : (*Block) -> void abi(.c) = xx b.invoke; invoke_fn(@b); diff --git a/examples/ffi-objc/1304-ffi-objc-block-multi-arg.sx b/examples/ffi-objc/1304-ffi-objc-block-multi-arg.sx index 595c8680..bab8b18b 100644 --- a/examples/ffi-objc/1304-ffi-objc-block-multi-arg.sx +++ b/examples/ffi-objc/1304-ffi-objc-block-multi-arg.sx @@ -43,7 +43,7 @@ g_sum: i32 = 0; g_tag: *void = null; main :: () -> i32 { - cl := (n: i32, tag: *void) => { + cl := (n: i32, tag: *void) { g_sum = n + 1; g_tag = tag; }; diff --git a/examples/ffi-objc/1305-ffi-objc-block-inline.sx b/examples/ffi-objc/1305-ffi-objc-block-inline.sx index d2d30135..f6147116 100644 --- a/examples/ffi-objc/1305-ffi-objc-block-inline.sx +++ b/examples/ffi-objc/1305-ffi-objc-block-inline.sx @@ -12,7 +12,7 @@ invoke_once :: (b: *Block) { main :: () -> i32 { x : i64 = 7; - invoke_once(xx () => { + invoke_once(xx () { print("inline block, x = {}\n", x); }); 0 diff --git a/examples/ffi-objc/1324-ffi-objc-arc-01-autoreleasepool.sx b/examples/ffi-objc/1324-ffi-objc-arc-01-autoreleasepool.sx index 3d24aa5d..a2c3f597 100644 --- a/examples/ffi-objc/1324-ffi-objc-arc-01-autoreleasepool.sx +++ b/examples/ffi-objc/1324-ffi-objc-arc-01-autoreleasepool.sx @@ -34,7 +34,7 @@ main :: () -> i32 { // (NSObject.new returns a +1 retained, NOT autoreleased), so this // is a smoke test of the helper's shape, not the runtime // behavior. - autoreleasepool(() => { + autoreleasepool(() { inner := NSObject.new(); if inner != null { inner.release(); diff --git a/examples/generics/0206-generics-generic-into-block.sx b/examples/generics/0206-generics-generic-into-block.sx index e7a82dbb..560e5455 100644 --- a/examples/generics/0206-generics-generic-into-block.sx +++ b/examples/generics/0206-generics-generic-into-block.sx @@ -24,7 +24,7 @@ g_a: i64 = 0; g_b: i64 = 0; main :: () -> i32 { - cl := (a: i64, b: i64) => { g_a = a; g_b = b; }; + cl := (a: i64, b: i64) { g_a = a; g_b = b; }; blk : Block = xx cl; invoke_fn : (*Block, i64, i64) -> void abi(.c) = xx blk.invoke; diff --git a/examples/optionals/0923-optionals-narrowing-no-closure-leak.sx b/examples/optionals/0923-optionals-narrowing-no-closure-leak.sx index de95e595..3c8e5798 100644 --- a/examples/optionals/0923-optionals-narrowing-no-closure-leak.sx +++ b/examples/optionals/0923-optionals-narrowing-no-closure-leak.sx @@ -17,7 +17,7 @@ main :: () { if n != null { // `n` is narrowed HERE, but the closure body is a separate function: // `n` is `?i64` inside it, so this implicit unwrap must be rejected. - g := () => { takes_i64(n); }; + g := () { takes_i64(n); }; g(); } } diff --git a/examples/optionals/expected/0923-optionals-narrowing-no-closure-leak.stderr b/examples/optionals/expected/0923-optionals-narrowing-no-closure-leak.stderr index b0e9907e..354ef83f 100644 --- a/examples/optionals/expected/0923-optionals-narrowing-no-closure-leak.stderr +++ b/examples/optionals/expected/0923-optionals-narrowing-no-closure-leak.stderr @@ -1,5 +1,5 @@ error: cannot use a value of type '?i64' where 'i64' is expected: an optional does not implicitly unwrap; force-unwrap with '!', supply a fallback with '?? ', bind it (`if v := ...`), or guard with '!= null' - --> examples/optionals/0923-optionals-narrowing-no-closure-leak.sx:20:22 + --> examples/optionals/0923-optionals-narrowing-no-closure-leak.sx:20:19 | -20 | g := () => { takes_i64(n); }; - | ^^^^^^^^^^^^ +20 | g := () { takes_i64(n); }; + | ^^^^^^^^^^^^ diff --git a/examples/types/0117-types-block-string-arg.sx b/examples/types/0117-types-block-string-arg.sx index 694ff96c..e314790d 100644 --- a/examples/types/0117-types-block-string-arg.sx +++ b/examples/types/0117-types-block-string-arg.sx @@ -18,7 +18,7 @@ g_s: string = ""; main :: () -> i32 { - cl := (s: string) => { g_s = s; }; + cl := (s: string) { g_s = s; }; b : Block = xx cl; invoke_fn : (*Block, string) -> void abi(.c) = xx b.invoke; invoke_fn(@b, "hello"); diff --git a/examples/types/0216-types-multi-return-closure.sx b/examples/types/0216-types-multi-return-closure.sx index c68a8cdd..0d5f7f31 100644 --- a/examples/types/0216-types-multi-return-closure.sx +++ b/examples/types/0216-types-multi-return-closure.sx @@ -1,7 +1,7 @@ // Multi-return CLOSURE types and lambda literals work via the same tuple // machinery as function multi-returns (D3): a `Closure() -> (A, B)` value's call // result destructures (`a, b := cb()`), single-binds with field access -// (`c := cb(); c.0`), and a `() => { return v1, v2; }` lambda literal satisfies a +// (`c := cb(); c.0`), and a `() { return v1, v2; }` lambda literal satisfies a // multi-return closure parameter. No dedicated ClosureInfo marker is needed — // the return slots ride as the reused `.tuple` TypeId, consistent with the // function-decl multi-return surface. @@ -13,14 +13,14 @@ apply :: (cb: Closure() -> (i32, bool)) -> i32 { } main :: () -> i64 { - cb : Closure() -> (i32, bool) = () => { return 7, true; }; + cb : Closure() -> (i32, bool) = () { return 7, true; }; x, y := cb(); print("{} {}\n", x, y); // 7 true c := cb(); // single-bind + positional field access print("{} {}\n", c.0, c.1); // 7 true - r := apply(() => { return 9, true; }); // lambda literal as the closure arg + r := apply(() { return 9, true; }); // lambda literal as the closure arg print("{}\n", r); // 9 return 0; } diff --git a/issues/0156-comptime-pack-captured-into-closure.sx b/issues/0156-comptime-pack-captured-into-closure.sx index 5103e5cb..ed111cac 100644 --- a/issues/0156-comptime-pack-captured-into-closure.sx +++ b/issues/0156-comptime-pack-captured-into-closure.sx @@ -14,7 +14,7 @@ main :: () { w := (a: i64, b: i64) -> i64 => a + b; t := .{40, 2}; out : i64 = 0; po := @out; - captured :: () => { po.* = w(..t); }; // tuple spread inside a closure → panics + captured :: () { po.* = w(..t); }; // tuple spread inside a closure → panics captured(); print("out: {}\n", out); // want: out: 42 (or a clean diagnostic) } diff --git a/library/modules/ffi/objc.sx b/library/modules/ffi/objc.sx index d6dc2125..cf9074b1 100644 --- a/library/modules/ffi/objc.sx +++ b/library/modules/ffi/objc.sx @@ -128,7 +128,7 @@ impl Into(*NSString) for string { // ─── Autoreleasepool (M4.A) ────────────────────────────────────────────── // Foundation factory methods (`NSString.stringWithUTF8String:`, // `[NSArray array]`, ...) return autoreleased objects — valid until the -// current pool drains. Wrap such code in `autoreleasepool(() => { ... })` +// current pool drains. Wrap such code in `autoreleasepool(() { ... })` // so the pool drains deterministically at block end. // // Stdlib helper, not a language keyword. The closure call adds a frame — diff --git a/library/modules/std/io.sx b/library/modules/std/io.sx index a3d7dcee..2b9ab9dd 100644 --- a/library/modules/std/io.sx +++ b/library/modules/std/io.sx @@ -151,7 +151,7 @@ sx_run_boxed_closure :: (arg: *void) { // the dealloc is a no-op. run_env := b.run.env; worker_env := b.worker_env; - if run_env != null { context.allocator.dealloc_bytes(run_env); } + if run_env != null { context.allocator.dealloc_bytes(run_env); } if worker_env != null { context.allocator.dealloc_bytes(worker_env); } context.allocator.dealloc_bytes(xx b); } @@ -222,7 +222,7 @@ async :: ufcs (io: Io, worker: Closure() -> ($R, !)) -> *Future($R) { // captured by-value into `run`'s env below, otherwise unreachable). `null` for // a capture-free worker. b.worker_env = worker.env; - b.run = () => { + b.run = () { f.value = worker() catch { if f.canceled.load(.acquire) { f.state = .canceled; } else { f.state = .failed; } @@ -282,7 +282,7 @@ await :: ufcs (f: *Future($R)) -> ($R, !IoErr) { f.consumed = true; fut_release(f); // frees the Future iff the worker has also finished if canceled { raise error.Canceled; } - if failed { raise error.Failed; } + if failed { raise error.Failed; } return v; } diff --git a/library/modules/std/sched.sx b/library/modules/std/sched.sx index 39f2d005..5d0bb597 100644 --- a/library/modules/std/sched.sx +++ b/library/modules/std/sched.sx @@ -619,7 +619,7 @@ impl Io for Scheduler { print("sched: spawn_raw called with a null entry function\n"); abort(); } - f := self.spawn(() => { + f := self.spawn(() { entry_fn : (*void) -> void = xx entry; entry_fn(arg); });