diff --git a/src/compiler/mod.rs b/src/compiler/mod.rs index 6e426eab..09c91152 100644 --- a/src/compiler/mod.rs +++ b/src/compiler/mod.rs @@ -1262,6 +1262,24 @@ impl AsyncArrowFunction { } } + pub(crate) fn compile( + self: &Rc, + chunk: &mut Chunk, + strict: bool, + source: &Rc, + ) -> anyhow::Result { + // Runtime Semantics: Evaluation + // + // The syntax-directed operation Evaluation takes argument env (an Environment Record) and returns either a + // normal completion containing a value or an abrupt completion. It is defined piecewise over the following + // productions: + // + // AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody + // CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + // 1. Return InstantiateAsyncArrowFunctionExpression of AsyncArrowFunction. + self.instantiate_async_arrow_function_expression(chunk, strict, source, None) + } + pub(crate) fn named_evaluation( self: &Rc, chunk: &mut Chunk, @@ -4950,7 +4968,9 @@ impl AssignmentExpression { AssignmentExpression::Arrow(arrow_function) => { arrow_function.compile(chunk, strict, source).map(CompilerStatusFlags::from) } - AssignmentExpression::AsyncArrow(_) => todo!(), + AssignmentExpression::AsyncArrow(node) => { + node.compile(chunk, strict, source).map(CompilerStatusFlags::from) + } AssignmentExpression::OpAssignment(lhse, op, rhs) => { // Stack: ... let lhs_status = lhse.compile(chunk, strict, source)?; diff --git a/src/compiler/tests.rs b/src/compiler/tests.rs index a9c6dbff..2c3b8c2e 100644 --- a/src/compiler/tests.rs +++ b/src/compiler/tests.rs @@ -3965,7 +3965,7 @@ mod assignment_expression { ]), true, false)); "lhse not abrupt")] #[test_case("x => 0", true, &[] => Ok((svec(&["00001: x => 0", "STRING 0 ()", "FUNC_IAE 0"]), true, false)); "arrow function")] #[test_case("yield 1", true, &[] => Ok((svec(&["00001: yield 1", "FLOAT 0 (1)", "YIELD"]), true, false)); "yield expr")] - #[test_case("async x => x", true, &[] => panics "not yet implemented"; "async arrow")] + #[test_case("async x => x", true, &[] => Ok((svec(&["00001: async x => x", "STRING 0 ()", "AFUN_IIFE 0"]), true, false)); "async arrow")] #[test_case( "a &&= b", true, &[] => Ok((