-
Notifications
You must be signed in to change notification settings - Fork 440
Add EffectfulExprSyntax
syntax trait
#2572
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
Conversation
Trait( | ||
traitName: "EffectfulExpr", | ||
documentation: "Syntax trait for effectful expressions, such as `try` and `await`.", | ||
children: [ | ||
Child(name: "expression", kind: .node(kind: .expr)) | ||
] | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably also expose the try
or await
keyword, similar to #2539
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've incorporated a keyword
property into the trait.
However, I have some reservations regarding this API, particularly because using the try
keyword without accompanying it with either a question mark or an exclamation mark might lead to confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you could expose an effectKeyword
property (mirroring tryKeyword
and awaitKeyword
) as well as a questionOrExclamationMark
property that's just always nil
for AwaitExprSyntax
?
(In the future, we could conceivably add some sort of await?
or await!
syntax and then the property would be automagically available. And no, I don't know what such syntax would do since it's purely hypothetical.)
Introduces the `EffectfulExprSyntax` protocol, designed to provide a common interface for effectful expressions such as `try` and `await`. Solves swiftlang#2549
b7fbd13
to
f19e5dd
Compare
If you do land this change, I'd like to get it cherry-picked to 600 so we can adopt it in swift-testing sooner. |
I don't see any problems with that on my end. Do you have an issue in swift-testing regarding adaptation? |
swift-testing should generally be able to adopt swift-syntax-600 features once the release is tagged; swift-syntax-610, speculatively, would be quite a ways off. |
Oh, I meant an issue about adopting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahoppen, please let me know if you want to land this PR in version 600. I will then move this release note to the 600.md
file.
I did find the time to actually think about it now and wasn’t able to come up with a concise definition that differentiates |
Introduces the
EffectfulExprSyntax
protocol, designed to provide a common interface for effectful expressions such astry
andawait
.Resolves #2549