swift icon indicating copy to clipboard operation
swift copied to clipboard

[SR-14229] [AutoDiff] conformance of synthesized TangentVector doesn't work

Open 83b09dda-53f5-4663-b44c-87fd2a9a8717 opened this issue 5 years ago • 2 comments

Previous ID SR-14229
Radar rdar://problem/81170168
Original Reporter @marcrasi
Type Bug

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, AutoDiff
Assignee None
Priority Medium

md5: 02544c29a1fa7eb644c287b7535e0342

is duplicated by:

  • SR-14959 [AutoDiff] Declaring protocol conformances for synthesized TangentVectors sometimes doesn't do anything

Issue Description:

Code:

public protocol P {}

public struct S: Differentiable {
  var x: Float = 0
  public init() {}

  //public struct TangentVector: AdditiveArithmetic, Differentiable {
  //  var x: Float = 0
  //}
  //public func move(along direction: TangentVector) { fatalError() }
}

extension S.TangentVector: P {}

func f<T: Differentiable>(_ t: T) where T.TangentVector: P {}

f(S())

Error:

module.swift:17:1: error: global function 'f' requires that 'S.TangentVector' conform to 'P'
f(S())
^
module.swift:15:6: note: where 'T.TangentVector' = 'S.TangentVector'
func f<T: Differentiable>(_ t: T) where T.TangentVector: P {}
     ^

This seems related to the synthesis because if you uncomment the custom TangentVector it compiles successfully.

@swift-ci create

rxwei avatar Jul 27 '21 18:07 rxwei

Issue still exists on 05/24 toolchain.

jkshtj avatar May 03 '24 20:05 jkshtj