You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MIR types a Task handle local as the awaited T; lower_single_await reads .f0 of an i32/i64-typed local (validator silent) #1464
Spec: §14 (a call of an async fn produces a Task[T]; .await produces the T). Found while fixing a regression in the #1444 branch (#1460).
MirLower types a local that holds a Task handle as the awaited T, not as Task[T], and then projects the handle's fiber id out of it as if T were a struct:
async fn double(x: i32): x * 2
fn main:
let t1 = double(5)
print(t1.await)
--dump-mir of main: the local for t1 is _1: ty3 (i32). In lower_single_await (MirLower.w), task_inner_ty = self.expr_type(inner) is also i32, materialize_operand(task_op, task_ty, …) copies the handle into another i32-typed temp, and new_field_place(task_place, 0, i32) reads field 0 of that i32 (call FIBER_WAS_CANCELLED_RETURN(copy _14.f0) with _14: ty4 in the async fn number(n: i64) case). The LLVM value in those locals is the task struct { i32, ptr }.
It worked only because codegen sized a memory local's slot from the stored value rather than from its declared type. When the #1444 branch sized slots from the declared type, store { i32, ptr } went into alloca i64 and alloca %Payload; the fiber id was read as an i64 (LLVM verifier: "Call parameter type does not match function signature!") and async_tuple_await.w segfaulted. The branch now sizes a slot by the value actually stored, which restores the old behavior for these locals, so this is latent again.
Tool gap: the typed MIR validator accepts a field projection (.f0) on an integer-typed local and a Task value assigned to a T-typed local.
Expected: Task-holding locals and lower_single_await's task_ty are Task[T] (Sema tracks the Task-ness as a binding side flag, scope_set_is_task, instead of in the type); the validator rejects a field projection on a non-aggregate type.
Activity
MIR/codegen: a discriminant enum's discriminant is a value of its rep…
MIR/codegen: a discriminant enum's discriminant is a value of its rep…
Sema: an unannotated async fn's calls are Task[T]; typed MIR rejects …
Sema: an unannotated async fn's calls are Task[T]; typed MIR rejects …
MIR: `for x in xs[i]` iterates the element list, not its buffer read …
MIR: `for x in xs[i]` iterates the element list, not its buffer read …