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

Fix type specialization during code generation #1560

Open
kyouko-taiga opened this issue Aug 17, 2024 · 0 comments
Open

Fix type specialization during code generation #1560

kyouko-taiga opened this issue Aug 17, 2024 · 0 comments

Comments

@kyouko-taiga
Copy link
Contributor

The following program crashes the compiler with an assertion failure (b5bd439):

trait P {
  type T: SemiRegular
  type U

  fun t(_ x: T)
  fun u(_ x: U)
}

trait Q: SemiRegular {
  type V: P
  property v: V { let }
}

type A<V: P & SemiRegular>: Q {
  public let _v: V
  public init (v: sink V) { &self._v = v }
  public property v: V { yield _v }
  public fun infix== (_ other: Self) -> Bool { self.v == other.v }
}

type B<W: Q>: Deinitializable {
  public let w: W
  public let tt: W.V.T
  public memberwise init

  public fun t(_ x: W.V.T) { w.v.t(x) }
  public fun u(_ x: W.V.U) { w.v.u(x) }
}

conformance Array: P {
  public typealias T = Element
  public typealias U = Self.Position

  public fun t(_ x: Element) {}
  public fun u(_ x: Self.Position) {}
}

public fun main() {
  let a = A(v: Array<Bool>())
  let b = B(w: a, tt: true)
  b.t(true)
  b.u(1)
}

Note: this program is adapted from this test.

The failure occurs in AbstractTypeLayout.swift and it is due to the layout B<A<Array<Bool>>> containing an error type. This error type is produced by the specialization of the generic type, which occurs in TypedProgram.storage(of:), under the "FIXME" note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant