Skip to content

Fix a comparison in an assertion #80347

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Sema/CodeSynthesisDistributedActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ void swift::assertRequiredSynthesizedPropertyOrder(ASTContext &Context,
}
if (idIdx + actorSystemIdx + unownedExecutorIdx >= 0 + 1 + 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's unclear what this if condition means. The logic above doesn't differentiate between the id field being missing, and the id being the first field. In both cases, idIdx is 0.

Now if all three fields are missing for example, we skip the assert. So we're only asserting that they have the correct order when present?

@ktoso Can you please explain the intent behind this code?

Copy link
Contributor

@ktoso ktoso Mar 28, 2025

Choose a reason for hiding this comment

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

It’s a bug if this order ever not as expected, I wanted to fix the warning earlier #79146 but yeah it’s a real bug that will need some investigation.

every distributed actor gets those fields synthesized. They MUST be in the specific order (ID then system) because IRGen will use them in this order in remote call accessors AFAIR. I’ll have to dig up the exact place.

We can close this PR as I have the other one I’ll get back to after some other bug fixes

// we have found all the necessary fields, let's assert their order
assert(idIdx < actorSystemIdx < unownedExecutorIdx &&
assert(idIdx < actorSystemIdx && actorSystemIdx < unownedExecutorIdx &&
"order of fields MUST be exact.");
}
}
Expand Down