Uploaded image for project: 'Swift'
  1. Swift
  2. SR-11989

Better diagnostic for invalid 'enclosing self' property wrapper subscript

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: None
    • Labels:

      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() }
        }
      }
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            slavapestov Slava Pestov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: