8000 "`EffectfulExprSyntax`" protocol covering `TryExprSyntax` and `AwaitExprSyntax` · Issue #2549 · swiftlang/swift-syntax · GitHub
[go: up one dir, main page]

Skip to content

"EffectfulExprSyntax" protocol covering TryExprSyntax and AwaitExprSyntax #2549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
grynspan opened this issue Mar 19, 2024 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@grynspan
Copy link
Contributor

Description

It'd be very helpful to have a protocol that covers all effectful expressions (currently TryExprSyntax and AwaitExprSyntax.) swift-testing needs to walk syntax trees and diagnose when either of these expression types appear in certain contexts, and because the types are unrelated there is a fair bit of duplicated logic between them.

@grynspan grynspan added the enhancement New feature or request label Mar 19, 2024
@ahoppen
Copy link
Member
ahoppen commented Mar 19, 2024

Tracked in Apple’s issue tracker as rdar://125011703

Matejkob added a commit to Matejkob/swift-syntax that referenced this issue Mar 27, 2024
Introduces the `EffectfulExprSyntax` protocol, designed to provide a common interface for effectful expressions such as `try` and `await`.

Solves swiftlang#2549
Matejkob added a commit to Matejkob/swift-syntax that referenced this issue Mar 29, 2024
Introduces the `EffectfulExprSyntax` protocol, designed to provide a common interface for effectful expressions such as `try` and `await`.

Solves swiftlang#2549
@ahoppen
Copy link
Member
ahoppen commented Apr 4, 2024

I did find the time to actually think about it now and wasn’t able to come up with a concise definition that differentiates TryExprSyntax and AwaitExprSyntax from any other syntax nodes, which is usually a very good indicator that we’re not on the right track.
At first I thought that try and await are keywords/modifiers/whatever you want to call them that don’t actually change semantic meaning but just indicate something to anyone reading the code. But TryExprSyntax also represents try! and try?, which do change how the expression behaves. With those in mind, I don’t think there’s anything fundamental that’s separating eg. try? from eg. optional chaining or force-unwrapping and thus it doesn’t make sense to add a syntax trait for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0