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-5224] Unable to detect infinite recursion defining lazy property #47799

Open
NachoSoto opened this issue Jun 14, 2017 · 4 comments
Open

[SR-5224] Unable to detect infinite recursion defining lazy property #47799

NachoSoto opened this issue Jun 14, 2017 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@NachoSoto
Copy link
Contributor

Previous ID SR-5224
Radar None
Original Reporter @NachoSoto
Type Bug
Environment

Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)
Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8)

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

md5: 2b5a78dc211ca710b14782a64e21ae98

relates to:

  • SR-626 No diagnostic for unconditional recursion

Issue Description:

This just bit me for the 1 millionth time (similar to SR-4406).

class C {
  lazy var a: String = { 
    let a = "test"
    print(self.a) // Do something with self.a instead of a (in my case it was self.contentView.addSubview(self.view) instead of self.contentView.addSubview(view))
    
    return a 
  }()
}
@belkadan
Copy link
Contributor

Slightly different than the others in that the current context isn't the getter itself.

@CodaFi
Copy link
Member

CodaFi commented Aug 24, 2017

This one is also tricky because of the called closure value. This creates an inter-procedural cycle that the optimizer eventually turns into direct self-recursion.

@NachoSoto
Copy link
Contributor Author

Hopefully this makes it in!

@NachoSoto
Copy link
Contributor Author

Addressed by #11869 <3

@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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

3 participants