Permalink
Browse files

Support concurrent blocks in reactive code

Summary: We need to whitelist awaitall as counting as being immediately awaited.

Reviewed By: vladima

Differential Revision: D13329905

fbshipit-source-id: 292afc3fd7d73544a4f9702b2e7011efc79bd81f
  • Loading branch information...
KendallHopkins authored and hhvm-bot committed Dec 5, 2018
1 parent 0b6b877 commit 5961bc11ac9a8772097b3e21cc5aeb45b686a4fb
@@ -464,6 +464,13 @@ let check = object(self)
disallow_static_or_global ~is_static:true el;
super#on_Static_var s el
method! on_Awaitall ((env, ctx) as s) _ els =
let allow_awaitable_s = (env, allow_awaitable ctx) in
List.iter els ~f:(fun (lhs, rhs) ->
Option.iter lhs ~f:(super#on_expr s);
super#on_expr allow_awaitable_s rhs
)
method! on_expr (env, ctx) expr =
let check_reactivity =
ctx.reactivity <> Nonreactive &&
@@ -0,0 +1,16 @@
<?hh // strict
<<__Rx>>
async function genx(): Awaitable<int> { return 42; }
<<__Rx>>
async function geny(): Awaitable<void> {}
<<__Rx>>
async function foo(): Awaitable<int> {
concurrent {
$x = await genx();
await geny();
$y = await genx();
}
return $x + $y;
}

0 comments on commit 5961bc1

Please sign in to comment.