reeva icon indicating copy to clipboard operation
reeva copied to clipboard

Implement Async Arrow Function

Open naijun0403 opened this issue 2 years ago • 0 comments

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()
        )
    )
}

naijun0403 avatar Nov 01 '23 14:11 naijun0403