swift
a1aace20 - [AutoDiff] Ban local-scope derivative registration. (#28483)

Commit
5 years ago
[AutoDiff] Ban local-scope derivative registration. (#28483) Fix a long-time hole in derivative registration: local scopes with possible captures. Derivative registration was not intended to support local scopes where a derivative function and an original function can have different closure contexts. Improper use of derivative registration in local scopes can result in crashers deeper down the compiler, e.g. TF-881. This PR bans derivative registration in local scopes by emitting diagnostics at parsing time. This applies to three attributes: 1. `@differentiable` with JVP or VJP specified. The `jvp:` and `vjp:` parameters in `@differentiable` will be banned as well as part of the retroactive derivative registration effort (TF-1001). 2. `@derivative(of:)`. 3. `@transpose(of:)` (today called `@transposing`). The diagnostics are emitted from the parser because there are precedents: access modifiers in local scopes are banned this way. Resolves SR-11849. Defines away TF-881.
Author
Parents
Loading