What is an UnresolvedAsExprSyntax?

"_ as Int" used to parse into two nodes: an underscore, and an AsExprSyntax.

now, under DEVELOPMENT-SNAPSHOT-2022-08-24-a, it is parsing into three nodes, with the as turning into an UnresolvedAsExprSyntax, and the Int becoming its own TypeSyntax node.

why did the AST change? and what is an UnresolvedAsExprSyntax anyway?

It was added in [Syntax] Introduce UnresolvedIsExpr/UnresolvedAsExpr by rintaro · Pull Request #60731 · apple/swift · GitHub & [Parser] Simplify sequence expression parsing by rintaro · Pull Request #628 · apple/swift-syntax · GitHub.

cc @rintaro who could provide you with more context.

1 Like

Yes, as I noted in the PR, we introduced UnresolvedIsExprSyntax/UnresolvedAsExprSyntax to guarantee SequenceExprSyntax have odd number elements. Previously, consumers needed to make exceptions for IsExpr / AsExpr. I think this change can simplify the handling of SequenceExprSyntax.


Right, it's setting up the invariants in SequenceExprSyntax, which are important for operator-precedence parsing.