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

[SR-14226] [AutoDiff]@derivative(of: subscript) crashes in stdlib #54407

Open
dan-zheng opened this issue Dec 23, 2019 · 0 comments
Open

[SR-14226] [AutoDiff]@derivative(of: subscript) crashes in stdlib #54407

dan-zheng opened this issue Dec 23, 2019 · 0 comments
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@dan-zheng
Copy link
Collaborator

Previous ID SR-14226
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: 816dc3ad01f6add55f3e37b85815b450

relates to:

  • TF-1094 .swiftinterface compilation: unserialized @derivative function is not registered for serialized @differentiable function

Issue Description:

`@derivative(of: subscript)` crashes in the stdlib: 73d43cf

Assertion failed: (!baseName.isSpecial() && "Can't retrieve the identifier of a special base name"), function getBaseIdentifier, file /Users/danielzheng/swift-build/swift/include/swift/AST/Identifier.h, line 469

The crash occurs in BuiltinUnit::lookupValue, called via TypeChecker::lookupUnqualified.


Strangely, a standalone reproducer does not crash:

extension SIMD2 {
  @differentiable(
    where Scalar : EuclideanDifferentiable & BinaryFloatingPoint,
          Scalar.TangentVector : BinaryFloatingPoint)
  public subscript(index index: Int) -> Scalar {
    @_transparent get { fatalError() }
    @_transparent set { fatalError() }
  }
}
extension SIMD2
  where Scalar : EuclideanDifferentiable & BinaryFloatingPoint,
        Scalar.TangentVector : BinaryFloatingPoint {
  @usableFromInline
  @derivative(of: subscript(index:))
  internal func _vjpSubscript(index: Int)
  -> (value: Scalar, pullback: (Scalar.TangentVector) -> TangentVector) {
    return (self[index], { v in
      var zeros = Self.zero
      zeros[index] = Scalar(v)
      return zeros
    })
  }
}
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant