Skip to content
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

More KJ_IF_SOME changes to workerd/api/streams #1215

Merged
merged 2 commits into from
Sep 21, 2023
Merged

Conversation

ohodson
Copy link
Contributor

@ohodson ohodson commented Sep 21, 2023

Finishes off workerd/api/streams

@ohodson ohodson changed the title More KJ_IF_SOME changes to workerd/streams More KJ_IF_SOME changes to workerd/api/streams Sep 21, 2023
This change leaves just standard.c++ to do. That has
dangling-else issues when migrated to KJ_IF_SOME.

Bug: EW-7618
Test: bazel test //...
Bug: EW-7618
Test: bazel test //...
@ohodson
Copy link
Contributor Author

ohodson commented Sep 21, 2023

Internal PR is 6269, passes tests there.

@ohodson
Copy link
Contributor Author

ohodson commented Sep 21, 2023

Internal PR is 6271, passes tests there (just waiting on x64-asan-release, passes x64-asan).

Copy link
Collaborator

@dom96 dom96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Big PR though, consider splitting up future ones more.

KJ_IF_SOME(pendingCancel, maybePendingCancel) {
maybeResolvePromise(js, pendingCancel.fulfiller);
} else {
// Else block to avert dangling else compiler warning.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, what is the compiler warning about when the else isn't here? Does KJ_IF_SOME generate an empty else?

Copy link
Contributor Author

@ohodson ohodson Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/capnproto/capnproto/blob/761aeb17563a59f43b3fe9bae93df83c6bd57d06/c%2B%2B/src/kj/common.h#L1353

KJ_IF_SOME has dangling if suppressions for the compiler, but it still complains in a few places. Complaints typically come with nested KJ_IF_SOME blocks, but also occur with a few other constructs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we fix KJ_IF_SOME for those cases?

Copy link
Contributor Author

@ohodson ohodson Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have a fix for now, or at least one we like, @harrishancock might have thoughts on this. I've come across maybe 7-8 places that it is an issue. For now, it seems reasonable to include the small intervention and document it, so it is a quick clean-up in future.

The problem is caused by KJ_IF_SOME wanting to support KJ_IF_SOME(..) {...} else {...}, when two are nested there are two if statements without else blocks and that is where the ambiguity comes from.

We might be able replace an if for a for, but that might also have drawbacks. Not tried.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be able replace an if for a for, but that might also have drawbacks. Not tried.

Ignore this, I don't see a way to make that work and support nesting.

@ohodson
Copy link
Contributor Author

ohodson commented Sep 21, 2023

Looks good. Big PR though, consider splitting up future ones more.

Thanks for reviewing. There are two commits that can be considered separately in the UX; still a good size though. The second commit is most of the work here and it's just standard.{c++,h}.

@dom96
Copy link
Collaborator

dom96 commented Sep 21, 2023

Ahh, I don't tend to review commit-by-commit.

@ohodson ohodson merged commit cf4457c into main Sep 21, 2023
7 checks passed
@ohodson ohodson deleted the orion/kj_if_some_streams branch September 21, 2023 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants