Skip to content

Implement Async Arrow Function #16

@naijun0403

Description

@naijun0403

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions