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-7281] Swift should diagnose infinite recursion of property observers #49829

Open
hamishknight opened this issue Mar 27, 2018 · 0 comments
Open
Labels
compiler The Swift compiler in itself improvement

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-7281
Radar None
Original Reporter @hamishknight
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement
Assignee CodaFi (JIRA)
Priority Medium

md5: af2b015f850708c51b08de1e32e3029e

Issue Description:

In #15526 we changed the behaviour of setting a property within its own didSet or willSet observer, such that we only perform direct accesses on self in Swift 5 mode.

However this means that code like this will now infinitely recurse:

struct S {
  var i = 0 {
    didSet {
      var s = self
      s.i = 5
    }
  }
}

var s = S()
s.i = 2

Ideally we should diagnose this with a warning.

@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
compiler The Swift compiler in itself improvement
Projects
None yet
Development

No branches or pull requests

1 participant