ReviewOS

home-lang/home

fix(types): preserve async values through await inference

#829
Closed glennmichael123 opened this 8 days ago ·
8 days ago

Problem

AwaitExpr currently falls through the checker's default Void result. As a consequence, locals initialized from await async_call() are typed void, and both examples/async_basic.home and examples/async.home fail when those locals are returned.

The checker also exposes an async call as its payload type directly, so it cannot reject await on ordinary values or distinguish a future from its resolved value.

Scope

  • Represent async call results as Future<T> in the semantic type system.
  • Mark function signatures as async without changing body return checking.
  • Unwrap Future<T> at await and reject awaiting non-future values.
  • Cover direct async calls, concrete awaited result types, and invalid awaits.
  • Re-run the examples acceptance gate.

Acceptance criteria

  • let value = await async_fn() infers the declared payload type.
  • Calling an async function without awaiting produces Future<T>, not T.
  • await 1 is a type error.
  • async_basic.home and async.home pass home check.

Part of #779 and #814.

8 days ago

Completed by 32875fc0d on origin/main. Async function signatures now retain an is_async bit, calls synthesize Future<T>, and await is the checked boundary that unwraps T; un-awaited futures no longer masquerade as payload values and non-futures are rejected. Guarded verification: checker 72/72, no-JSC build at 2,819 MB peak, and examples improved 34/39 → 36/39 with both async_basic.home and async.home now passing.

Sign in to comment on this issue.