Created
September 3, 2019 23:49
-
-
Save marii-moe/80cc8e263631ee1e0b4b9d507a3ad2de to your computer and use it in GitHub Desktop.
Test that reproduces compiler error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RUN: %target-run-simple-swift | |
// REQUIRES: executable_test import StdlibUnittest | |
#if os(macOS) | |
import Darwin.C | |
#else | |
import Glibc | |
#endif | |
var OptionalTests = TestSuite("Optional") | |
typealias OptionalGrad = Optional<Float>.TangentVector | |
extension Optional: Differentiable where Wrapped: Differentiable { | |
public struct TangentVector: Differentiable, | |
AdditiveArithmetic { | |
public var value: Wrapped.TangentVector? | |
public init(value: Wrapped.TangentVector?) { | |
self.value = value | |
} | |
public static var zero: Self { | |
get { Self(value: Wrapped.TangentVector.zero) } | |
} | |
public static func + (lhs: Self, rhs: Self) -> Self { | |
return self.zero | |
} | |
public static func - (lhs: Self, rhs: Self) -> Self { | |
return self.zero | |
} | |
public typealias TangentVector = Self | |
} | |
public mutating func move(along direction: TangentVector) -> () { | |
return //self = self.zeroTangentVector //self?.move(along: direction.value!) } | |
public var zeroTangentVector: TangentVector { | |
return TangentVector.zero //TangentVector(value: .zero) | |
} | |
} | |
OptionalTests.test("Optional Dense") { | |
func optIdentity( _ f1: Optional<Float>) -> Optional<Float>{ | |
return f1 | |
} | |
let backprop = pullback(at: 5, in: optIdentity) | |
expectEqual(1,1) | |
} | |
runAllTests() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment