style: migrate arrow-block lambdas () => { .. } to () { .. }
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user