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-10297] Try to transform init call on the instance of type to an assignment #52697

Closed
xedin opened this issue Apr 3, 2019 · 0 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@xedin
Copy link
Member

xedin commented Apr 3, 2019

Previous ID SR-10297
Radar rdar://problem/36036244
Original Reporter @xedin
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee slazarus (JIRA)
Priority Medium

md5: e021780c97db9aa203896ca4525bcbfb

Issue Description:

Consider following example:

struct X { init(_:Int, _:Int){  } }

struct Y {
  var x: X
  init() {
    x.init(3, 3)
  }
}

It produces following diagnostic:

error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
      x.init(3, 3)
      ^
        type(of:  )

Instead it should suggest to transform this expression into an assignment and error should say that it's incorrect to call `init` on value of type `X`.

    x = .init(3, 3)
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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 diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant