You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 1, 2023. It is now read-only.
[Tensor] Add precondition in 'Tensor.init(arrayLiteral:)' to reject 'init()' calls. (#336)
A long-standing issue in Swift is that labeled variadic parameters can accept 0 arguments when a label does not exist. Here is a related discussion on Swift Evolution: [Should labeled variadic parameters accept 0 arguments?](https://forums.swift.org/t/should-labeled-variadic-parameters-accept-0-arguments/12500)
When there is no `Tensor.init()`, an `init()` expression will resolve to a call to `init(arrayLiteral:)` with no arguments, which is semantically invalid for `Tensor`, `ShapedArray`, and `ShapedArraySlice`. Declaring an `init()` with an `@available(*, unavailable)` does not work becuase the type checker would still resolve `init()` calls to `init(arrayLiteral:)`. Before Swift supports finer control over labeled variadic parameters, the only thing we can do is to fail early at run-time.
XCTest does not yet provide test utilities for crashers. We can add such a test utility along with tests for such run-time errors later.
Resolves [TF-644](https://bugs.swift.org/browse/TF-644).
0 commit comments