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

Swift: dataflow for for-in loops #13909

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rdmarsh2
Copy link
Contributor

@rdmarsh2 rdmarsh2 commented Aug 7, 2023

No description provided.

@rdmarsh2
Copy link
Contributor Author

rdmarsh2 commented Aug 7, 2023

This is built on top of #13838 - only the last two commits are new

Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

This is pleasingly straightforward!

I'd like to see iteration through CollectionElement supported + tested in addition to ArrayContent.

for entry in arr7
{
sink(arg: entry) // $ flow=696
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I doubt it will affect flow, but it might also be nice to have one test in the alternative form:

arr7.forEach { entry in
	sink(arg: entry) // $ flow=
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, but doesn't work - I think that's syntactically a call to the method forEach that takes a closure as an argument.

@rdmarsh2
Copy link
Contributor Author

rdmarsh2 commented Aug 8, 2023

Actually after starting on dictionaries I'm no longer sure this is the right way to do this - I think there's an implicit call that generates an iterator or something, and this PR won't capture the behavior of dictionaries properly.

@rdmarsh2 rdmarsh2 closed this Aug 8, 2023
@rdmarsh2
Copy link
Contributor Author

rdmarsh2 commented Aug 11, 2023

After rethinking how dictionary flow is implemented I think this will work properly for dictionaries. There's still some weirder options (self-iterators and such) that won't be handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants