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-10092] Custom initializers always call member initializers #52494

Open
Azoy opened this issue Mar 12, 2019 · 1 comment
Open

[SR-10092] Custom initializers always call member initializers #52494

Azoy opened this issue Mar 12, 2019 · 1 comment
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@Azoy
Copy link
Member

Azoy commented Mar 12, 2019

Previous ID SR-10092
Radar None
Original Reporter @Azoy
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @Azoy
Priority Medium

md5: db7359379f23291a48589aff8b172323

Issue Description:

During SE-0242 (https://forums.swift.org/t/se-0242-synthesize-default-values-for-the-memberwise-initializer/20618/1), there was discussion about how the compiler currently treats initializers for structs and classes.

func zero() -> Int {
  print("hello")
  return 0
}

struct X {
  var y = zero()

  init(y: Int) {
    self.y = y
  }
}

let x = X(y: 10) // hello

This behavior does not occur with memberwise initializers because they are lowered differently, but user defined initializers all have this same behavior.

Accepting rationale stated that the core team felt this behavior was a bug
(https://forums.swift.org/t/se-0242-synthesize-default-values-for-the-memberwise-initializer/20618/98).

This is a somewhat complicated issue and I plan to write a much longer topic on the forums discussing this and getting some feedback there. I'll post the link here when I get done writing it.

@Azoy
Copy link
Member Author

Azoy commented Mar 12, 2019

@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

1 participant