reeva
reeva copied to clipboard
Implement Async Arrow Function
Summary
Both async function and arrow function seem to work, but they don't work if you use them together.
Spec
VM: GraalVM 17.0.8 OS: macOS 14
Error
1: const a = async () => {}
^
2: console.log(a)
SyntaxError: expected function, but found (
Example
const a = async () => {}
console.log(a)
import com.reevajs.reeva.Reeva
import com.reevajs.reeva.core.Agent
import com.reevajs.reeva.core.lifecycle.LiteralSourceInfo
fun main() {
val agent = Agent.build()
agent.enter()
println(
Reeva.execute(
LiteralSourceInfo(
"test",
"""
const a = async () => {}
console.log(a)
""".trimIndent(),
false
),
agent.makeRealmAndInitializeExecutionEnvironment()
)
)
}