What do downloadable toolchains contain?

Hi, I downloaded the last trunk development (main) snapshot (January 17, 2021). One week ago @hborla's #35218 has been merged both in the main and in the release/5.4 branches. Is it correct to expect it to be available in the downloaded toolchain? Are there any delays involved?

Specifically, I'm getting undefined behavior when initializing structs involving the property wrappers provided in the tests:

@propertyWrapper
final class ClassWrapper<T> {
  private var _wrappedValue: T
  var wrappedValue: T {
    get { _wrappedValue }
    set {
      print(" .. set \(newValue)")
      _wrappedValue = newValue
    }
  }

  init(wrappedValue: T) {
    print(" .. init \(wrappedValue)")
    self._wrappedValue = wrappedValue
  }
}

struct StructWithClassWrapper<T> {
  @ClassWrapper private var _storage: T?

   init(value: T?) {
     _storage = value
  }
}

StructWithClassWrapper(value: 3)

The last line results in a compiler error:

Playground execution aborted: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff8).
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.

But if in the playground page I add:

import SwiftUI

struct S<T> {
  @State var value: Int?

  init() {
    value = 10
  }
}

then no compiler error shows up and the following error gets printed in console at runtime:

error: Couldn't lookup symbols:
  SwiftUI.State.init(wrappedValue: τ_0_0) -> SwiftUI.State<τ_0_0>
  SwiftUI.State.init(wrappedValue: τ_0_0) -> SwiftUI.State<τ_0_0>
  SwiftUI.State.init(wrappedValue: τ_0_0) -> SwiftUI.State<τ_0_0>
  SwiftUI.State.init(wrappedValue: τ_0_0) -> SwiftUI.State<τ_0_0>
  SwiftUI.State.init(wrappedValue: τ_0_0) -> SwiftUI.State<τ_0_0>
  SwiftUI.State.init(wrappedValue: τ_0_0) -> SwiftUI.State<τ_0_0>
  SwiftUI.State.init(wrappedValue: τ_0_0) -> SwiftUI.State<τ_0_0>

I have no clues on what and why is happening. Is it because the built toolchain doesn't include that pull request? Is it because I'm using a Playground?

Thank you in advance!

I vaguely remember Playgrounds not supporting custom toolchains, but I don't remember the reason why. My property wrapper DI fix should be in the main development toolchain you downloaded. You can check this by clicking on a commit from #35218 and looking for a swift-DEVELOPMENT-SNAPSHOT-... tag and checking the date:

I downloaded the main snapshot from January 17th and tried the example you posted from the test suite, and it compiles successfully in a command line tool Xcode project.

1 Like

Thank you! So I should never use Playgrounds to test toolchains.

Terms of Service

Privacy Policy

Cookie Policy