swift icon indicating copy to clipboard operation
swift copied to clipboard

[SR-14222] [AutoDiff] Incorrect derivative for array literal with `tuple_element_addr` elements

Open dan-zheng opened this issue 5 years ago • 1 comments

Previous ID SR-14222
Radar None
Original Reporter @dan-zheng
Type Bug

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

md5: 0184cfd78c8d9dc3932d9cb75b334ce8

Issue Description:

func tupleElementGeneric<T>(_ x: T, _ y: T) -> [T] {
  var tuple = (x, y)
  return [tuple.0, tuple.1]
}
let pb = pullback(at: Float(3), 4, in: { tupleElementGeneric($0, $1) })
print(pb(.init([1, 1])))
//   Actual: (0.0, 2.0)
// Expected: (1.0, 1.0)

dan-zheng avatar Nov 18 '19 23:11 dan-zheng

Throws an error on the 05/24 toolchain.

/Users/kshitij/workspace/scratch/test.swift:7:18: error: incorrect argument label in call (have 'at:_:in:', expected 'at:_:of:')
 5 |   return [tuple.0, tuple.1]
 6 | }
 7 | let pb = pullback(at: Float(3), 4, in: { tupleElementGeneric($0, $1) })
   |                  `- error: incorrect argument label in call (have 'at:_:in:', expected 'at:_:of:')
 8 | print(pb(.init([1, 1])))
 9 |

/Users/kshitij/workspace/scratch/test.swift:8:11: error: cannot infer contextual base in reference to member 'init'
 6 | }
 7 | let pb = pullback(at: Float(3), 4, in: { tupleElementGeneric($0, $1) })
 8 | print(pb(.init([1, 1])))
   |           `- error: cannot infer contextual base in reference to member 'init'
 9 |
10 | //   Actual: (0.0, 2.0)

jkshtj avatar May 03 '24 20:05 jkshtj