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

Improper autocorrect for optional lazy vars. #1334

Closed
bclymer opened this issue Feb 27, 2017 · 1 comment
Closed

Improper autocorrect for optional lazy vars. #1334

bclymer opened this issue Feb 27, 2017 · 1 comment
Labels
bug Unexpected and reproducible misbehavior.

Comments

@bclymer
Copy link

bclymer commented Feb 27, 2017

I found what is definitely an edge case, but still a valid case of autocorrect producing source that won't compile.

Running autocorrect on the following file

class TestClass {
    private lazy var test: Int? = nil
}

will produce the output

class TestClass {
    private lazy var test: Int?
}

Xcode will then let you know lazy vars require an initializer.

If the code is

class TestClass {
    private lazy var test: Int? = 0
}

Everything is fine. It only happens with nil.

Obviously, having a lazy var initialize to nil makes no sense. No clue why it was written like that.

I could also see this being a reasonable warning to add. lazy var x: Any? = nil is probably a smell.

@bclymer bclymer changed the title Improper autocorrect for lazy vars. Improper autocorrect for optional lazy vars. Feb 27, 2017
@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label Feb 28, 2017
@jpsim
Copy link
Collaborator

jpsim commented Mar 10, 2017

We should definitely fix this, but it's probably super low priority for the reasons you've outlined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

No branches or pull requests

3 participants