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-11989] Better diagnostic for invalid 'enclosing self' property wrapper subscript #54422

Open
slavapestov opened this issue Jan 3, 2020 · 7 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers property wrappers Feature: property wrappers swift 5.9

Comments

@slavapestov
Copy link
Contributor

slavapestov commented Jan 3, 2020

Previous ID SR-11989
Radar rdar://problem/58438128
Original Reporter @slavapestov
Type Bug
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug, StarterBug
Assignee janebond (JIRA)
Priority Medium

md5: 20d8a77f9190fc316ad55bfd7bb733b2

Issue Description:

This used to emit bad diagnostics and then crash the compiler. I've fixed the crash but we need to fix the bad diagnostic:

public class Store {
    @Published public var state: Any
    init() {
      self.state = 0
    }
}

@propertyWrapper public struct Published<Value> {
  public init(wrappedValue: Value) {}
  public var wrappedValue: Value {
    get { fatalError() }
    set {}
  }
  public static subscript(_enclosingInstance object: Any,
                          wrapped wrappedKeyPath: Any,
                          storage storageKeyPath: Any)
      -> Value {
    get { fatalError() }
    set {}
  }
  public struct Publisher {}
  public var projectedValue: Publisher {
    mutating get { fatalError() }
  }
}
@slavapestov
Copy link
Contributor Author

@swift-ci create

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci create

@slavapestov
Copy link
Contributor Author

I also added this FIXME to buildStorageReference(); probably it should be addressed at the same time:

    // FIXME: Since we're not resolving overloads or anything, we should be
    // building fully type-checked AST above; we already have all the
    // information that we need.

@swift-ci
Copy link
Contributor

Comment by Hassan ElDesouky (JIRA)

@slavapestov Can you provide more details?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation property wrappers Feature: property wrappers swift 5.9 labels Jul 27, 2023
@jacbro2021
Copy link

Is anyone working on this ticket / could this be assigned to me? Not seeing the ability to self-assign in the top right.

@ziad-ashraf7
Copy link

ziad-ashraf7 commented Mar 20, 2025

Is anyone working on this ticket / could this be assigned to me? Not seeing the ability to self-assign in the top right.

is it required to be assigned to the issue before working on it? I didn't see this in the Contribution guide.
That's because I've already started working on this issue 2 days before!

Image

I think my bad was I forgot to at least leave a comment to say that

@ziad-ashraf7
Copy link

ziad-ashraf7 commented Mar 23, 2025

Hi @slavapestov , just wanted to ask you for more details about the error
now I ran the code you provided on my machine and i got this error

Image

so my question is:

is this the bad diagnostic that you are talking about?

backing the to your PR that you solved the compiler crash
#28988

i found that you wrote this in your test file test/decl/var/property_wrappers_invalid.swift

// FIXME: This should produce a diagnostic with a proper
// source location. Right now, we just get three useless errors:

// <unknown>:0: error: type of expression is ambiguous without more context
// <unknown>:0: error: type of expression is ambiguous without more context
// <unknown>:0: error: type of expression is ambiguous without more context

So it was expected for me to get these errors

// <unknown>:0: error: type of expression is ambiguous without more context
// <unknown>:0: error: type of expression is ambiguous without more context
// <unknown>:0: error: type of expression is ambiguous without more context

but I found the errors in the pic.

is this the "unclear diagnostic" that you are talking about?
if yes, could you please suggest to me how to make it much better?

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 itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers property wrappers Feature: property wrappers swift 5.9
Projects
None yet
Development

No branches or pull requests

5 participants