Skip to content

Consume: warn about no-op consumes to be fixed #75449

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 2 commits into from
Jul 25, 2024

Conversation

kavon
Copy link
Member

@kavon kavon commented Jul 24, 2024

As of now, SE-366 is not correctly implemented with respect to concrete, bitwise-copyable types like Int. Writing consume someInt doesn't actually consume the variable binding as it should, meaning code that should be flagged as having a use-after-consume is being silently permitted:

let someInt = 10
let y = consume someInt
print(someInt) // no error!

This has been a problem since Swift 5.9. Eventually we plan to fix this issue, which means code previously doing the above would become an error. To help people get ready for the fix, start warning people that these consumes are actually no-ops and suggest removing them until the intended behavior is actually enforced in the future.

resolves rdar://127081103

@kavon
Copy link
Member Author

kavon commented Jul 24, 2024

@swift-ci test

@kavon
Copy link
Member Author

kavon commented Jul 24, 2024

@swift-ci please test source compatability

@kavon
Copy link
Member Author

kavon commented Jul 24, 2024

@swift-ci please test source compatibility

kavon added 2 commits July 24, 2024 16:05
As of now, SE-366 is not correctly implemented with respect to concrete,
bitwise-copyable types like `Int`. Writing `consume someInt` doesn't
actually consume the variable binding as it should, meaning code that
should be flagged as having a use-after-consume is being silently
permitted:

```swift
let someInt = 10
let y = consume someInt
print(someInt) // no error!
```

This has been a problem since Swift 5.9. Eventually we plan to fix this
issue, which means code previously doing the above would become an
error. To help people get ready for the fix, start warning people that
these consumes are actually no-ops and suggest removing them until the
intended behavior is actually enforced in the future.

resolves rdar://127081103
@kavon
Copy link
Member Author

kavon commented Jul 24, 2024

@swift-ci smoke test

@kavon kavon enabled auto-merge July 24, 2024 23:14
@kavon kavon merged commit dfeb52b into swiftlang:main Jul 25, 2024
3 checks passed
@kavon kavon deleted the kavon-fixes-2 branch July 25, 2024 03:26
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.

1 participant