Skip to content

[CSGen] Emulate separate type-checking of $generator variable of for-in loop #59560

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

Merged
merged 1 commit into from
Jun 21, 2022

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jun 18, 2022

Emulate previous for-in type-checking behavior where sequence
was type-checked separately from .next() call which, in turn,
was injected only during SIL generation.

Current approach to generate an implicit variable for $generator
and use it as a base to .next() call didn't account for the fact
that it allows the solver to rank result of <sequence>.makeIterator()
together with result of next(). This is logically incorrect because
<sequence>.makeIterator() represents initializer of $generator
which is separate from $generator.next() expression albeit type-checked
together.

Resolves: #59522

…r-in loop

Emulate previous `for-in` type-checking behavior where sequence
was type-checked separately from `.next()` call which, in turn,
was injected only during SIL generation.

Current approach to generate an implicit variable for `$generator`
and use it as a base to `.next()` call didn't account for the fact
that it allows the solver to rank result of `<sequence>.makeIterator()`
together with result of `next()`. This is logically incorrect because
`<sequence>.makeIterator()` represents initializer of `$generator`
which is separate from `$generator.next()` expression albeit type-checked
together.

Resolves: swiftlang#59522
@xedin xedin requested a review from hborla June 18, 2022 06:37
@xedin
Copy link
Contributor Author

xedin commented Jun 18, 2022

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Jun 18, 2022

@swift-ci please test source compatibility

@xedin xedin merged commit b897654 into swiftlang:main Jun 21, 2022
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.

Generic overload resolution fails in for-in statement
2 participants