fix: use generated tuple representation for Await AST nodes

This commit is contained in:
2026-10-23 20:15:49 +08:00
parent ae75c54707
commit 89b817447e
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -332,7 +332,7 @@ impl Builder {
binding, binding,
}); });
} }
ExprKind::Unary { operand, .. } | ExprKind::Await { operand } => { ExprKind::Unary { operand, .. } | ExprKind::Await(operand) => {
self.expression(operand, globals)? self.expression(operand, globals)?
} }
ExprKind::Binary { left, right, .. } => { ExprKind::Binary { left, right, .. } => {
+1 -1
View File
@@ -300,7 +300,7 @@ impl<'a> Emitter<'a> {
} }
self.emit(Opcode::Call, arguments.len())?; self.emit(Opcode::Call, arguments.len())?;
} }
ExprKind::Await { operand } => { ExprKind::Await(operand) => {
self.expression(operand)?; self.expression(operand)?;
self.simple(Opcode::Await); self.simple(Opcode::Await);
} }
+1 -1
View File
@@ -147,7 +147,7 @@ peg::parser! {
left:(@) slash() right:@ { binary(left, BinaryOp::Divide, right) } left:(@) slash() right:@ { binary(left, BinaryOp::Divide, right) }
-- --
start:keyword("await") operand:@ { start:keyword("await") operand:@ {
Expr { span: start.through(operand.span), kind: ExprKind::Await { operand: Box::new(operand) } } Expr { span: start.through(operand.span), kind: ExprKind::Await(Box::new(operand)) }
} }
start:minus() operand:@ { start:minus() operand:@ {
Expr { span: start.through(operand.span), kind: ExprKind::Unary { operation: UnaryOp::Negate, operand: Box::new(operand) } } Expr { span: start.through(operand.span), kind: ExprKind::Unary { operation: UnaryOp::Negate, operand: Box::new(operand) } }
+1 -1
View File
@@ -84,4 +84,4 @@ use、namespace、trait、agent、完整类型语法、条件/循环、比较
源码类实现子集采用 `class Name: Base { field: TypeName function method(self: Name): ResultType { ... } }`;基类可省略,执行环境须提供 Object。成员函数沿用既有 function 语法,接收者 self 为显式首参数。普通类字段按基类字段、再本类字段的顺序接收位置构造实参。这里记录实现范围,不确认语言文档中的全部候选构造语法;详细限制见[名义类型](types.md)。 源码类实现子集采用 `class Name: Base { field: TypeName function method(self: Name): ResultType { ... } }`;基类可省略,执行环境须提供 Object。成员函数沿用既有 function 语法,接收者 self 为显式首参数。普通类字段按基类字段、再本类字段的顺序接收位置构造实参。这里记录实现范围,不确认语言文档中的全部候选构造语法;详细限制见[名义类型](types.md)。
`await expression` 解析为 ExprKind::Await { operand },优先级与前缀负号同级,成员/调用绑定更紧;例如await task.result()等待该调用的返回对象,(await task).field先等待task。await按表达式前缀位置识别,不引入async函数声明。执行是否允许等待由调用上下文决定,见字节码VM的Await章节。 `await expression` 解析为 ExprKind::Await(operand),优先级与前缀负号同级,成员/调用绑定更紧;例如await task.result()等待该调用的返回对象,(await task).field先等待task。await按表达式前缀位置识别,不引入async函数声明。执行是否允许等待由调用上下文决定,见字节码VM的Await章节。