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:
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user