Navigation Menu

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-11060] Inappropriate property wrapper error fixit #53452

Closed
Agarunov opened this issue Jul 2, 2019 · 5 comments
Closed

[SR-11060] Inappropriate property wrapper error fixit #53452

Agarunov opened this issue Jul 2, 2019 · 5 comments
Assignees
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 property wrappers Feature: property wrappers

Comments

@Agarunov
Copy link

Agarunov commented Jul 2, 2019

Previous ID SR-11060
Radar rdar://problem/52593306
Original Reporter @Agarunov
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 11.0 beta 3 (11M362v)

Toolchain: Swift 5.1 Snapshot 2019-07-01 (a)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, PropertyWrappers, StarterBug
Assignee @theblixguy
Priority Medium

md5: 9b11c636912315097debd09fd628182d

Issue Description:

If i apply fixit for error in this code:

class Value {
    // error: Missing argument for parameter 'string' in call
    @A var some: Int = 100
}


@propertyWrapper
struct A {
    var wrappedValue: Int
    
    init(initialValue: Int, string: String) {
        self.wrappedValue = initialValue
    }
}

Then I get invalid code:

class Value {
    @A var some: Int = 100, string: <#String#>
}


@propertyWrapper
struct A {
    var wrappedValue: Int
    
    init(initialValue: Int, string: String) {
        self.wrappedValue = initialValue
    }
}
@belkadan
Copy link
Contributor

belkadan commented Jul 3, 2019

Ha. cc @xedin

@swift-ci create

@DougGregor
Copy link
Member

Fun. Looks like we'll need to customize the diagnostic when it's an implicitly-generated initializer call that fails.

@roop
Copy link
Mannequin

roop mannequin commented Jul 9, 2019

I’d like to work on this bug. But it looks hard and I think I’ll need some help (or lots of it).

This is what I understand of this problem so far:

  • The initializer call for the property wrapper is synthesised and added to the AST in maybeApplyPropertyWrapper() in TypeCheckConstraints.cpp

  • The matching of the synthesized initializer call with whatever is defined in the @propertyWrapper type takes the normal function call matching route (which doesn’t do anything special for property wrappers)

  • The fixit is emitted in missingArgument() in CSDiag.cpp, and from its perspective, the fixit should be inserted inside of a call that doesn’t actually exist in the source code — hence the wrong location for the fixit

To go about fixing it, I think missingArgument() should get to know whether it’s a property wrapper initializer or not, and handle that case differently.

@roop
Copy link
Mannequin

roop mannequin commented Jul 13, 2019

I’m afraid I will not be working on this for a few more days. I hope to work on this on Tue 16/Jul.

@theblixguy
Copy link
Collaborator

Fixed on master: #26219

@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 property wrappers Feature: property wrappers
Projects
None yet
Development

No branches or pull requests

4 participants