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

Spurious error after wrapped 'var' declaration without type annotation.

    XMLWordPrintable

    Details

      Description

      @propertyWrapper
      struct Wrap {
        var wrappedValue: Int = 1
      }
      func test() {
        @Wrap var val
        _ = val
      }
      

      This results:

      test.swift:8:3: error: found an unexpected second identifier in variable declaration; is there an accidental break?
        _ = val
        ^
      test.swift:8:3: note: join the identifiers together
        _ = val
      ~~^
      val_
      test.swift:8:7: error: use of local variable 'val' before its declaration
        _ = val
            ^
      test.swift:7:13: note: 'val' declared here
        @Wrap var val
                  ^
      

      But this should be valid syntax.

        Attachments

          Activity

            People

            Assignee:
            nate041 Nhat Dinh
            Reporter:
            rintaro Rintaro Ishizaki
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: