- Notifications
You must be signed in to change notification settings - Fork 471
Labels
Description
- Is it a bug? Usage questions should often be asked in the forum instead.
- Concise, focused, friendly issue title & description.
- A minimal, reproducible example.
- OS and browser versions, if relevant.
- Is it already fixed in master? Instructions
On version 12.0.0-rc.2
I don't think this feature of using @directive
on a function is documented. Anyway it works well and it's useful for frameworks like NextJs.
The problem seems to be the parameter parsing with async functions.
So this fails to compile - Await on expression not in async context
error for the line with await
.
let f = @directive("'use cache'") async (p1, ~p2, ~p3) => { await Promise.make((resolve, _reject) => resolve((p1, p2, p3)) }
While this compiles (with zero or one parameters):
let f = @directive("'use cache'") async (p1) => { await Promise.make((resolve, _reject) => resolve((p1))) }
And this also compiles (without async):
let f = @directive("'use cache'") (p1, ~p2, ~p3) => { Promise.make((resolve, _reject) => resolve((p1, p2, p3))) }
So zero or one parameters compile with async, more than one parameter fails to compile with async. While without async, any number of parameters compile correctly. So I can find a workaround by not using async, if I need multiple parameters. However this looks like a bug.