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

[SR-15670] 'let' property reinitialization checking is flow-insensitive #57949

WowbaggersLiquidLunch opened this issue Dec 30, 2021 · 0 comments


Copy link

@WowbaggersLiquidLunch WowbaggersLiquidLunch commented Dec 30, 2021

Previous ID SR-15670
Radar None
Original Reporter @WowbaggersLiquidLunch
Type Bug

macOS 12.2 Beta (21D5025f)
2021-12-23 trunk snapshot

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 585be41f2a676f040b3b7a4a7d219034


  • SR-6945 Error in struct init, saying 'self' used before assignment for the assignment itself

relates to:

  • SR-15669 Diagnostics for reinitialization of ‘let’ property due to initilizer delegation is misleading

Issue Description:

Currently, as long as there exists a delegation somewhere in an initializer, let properties are not allowed to be initialised directly, even if the delegation is unreachable.

struct S {
    let x: Int

extension S {
    init(a: Int) {
        guard true else {
            self.init(x: a)
        x = a // error: 'let' property ‘x’ may not be initialized directly; use "self.init(...)" or "self = ..." instead

This should be changed to be flow-sensitive, so it should be ok so long as every let property is initialized only once on each path.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

1 participant