Skip to content

Commit e9fb45f

Browse files
committed
Make stored props/vars not have custom VJPs/JVPs.
1 parent 0151aff commit e9fb45f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,8 +2733,8 @@ ERROR(differentiable_attr_unsupported_req_kind,none,
27332733
"layout requirement are not supported by '@differentiable' attribute", ())
27342734
ERROR(differentiable_attr_class_unsupported,none,
27352735
"class members cannot be marked with '@differentiable'", ())
2736-
ERROR(differentiable_attr_stored_property_unsupported,none,
2737-
"stored properties cannot be marked with '@differentiable'", ())
2736+
ERROR(differentiable_attr_stored_property_variable_unsupported,none,
2737+
"stored properties/variables cannot be marked with '@differentiable' with a custom VJP/JVP", ())
27382738
NOTE(protocol_witness_missing_specific_differentiable_attr,none,
27392739
"candidate is missing attribute '%0'", (StringRef))
27402740

lib/Sema/TypeCheckAttr.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,8 +2887,10 @@ void AttributeChecker::visitDifferentiableAttr(DifferentiableAttr *attr) {
28872887

28882888
AbstractFunctionDecl *original = dyn_cast<AbstractFunctionDecl>(D);
28892889
if (auto *asd = dyn_cast<AbstractStorageDecl>(D)) {
2890-
if (asd->getImplInfo().isSimpleStored()) {
2891-
diagnoseAndRemoveAttr(attr, diag::differentiable_attr_stored_property_unsupported);
2890+
if (asd->getImplInfo().isSimpleStored() &&
2891+
(attr->getJVP() || attr->getVJP())) {
2892+
diagnoseAndRemoveAttr(attr,
2893+
diag::differentiable_attr_stored_property_variable_unsupported);
28922894
return;
28932895
}
28942896
// When used directly on a storage decl (stored/computed property or

0 commit comments

Comments
 (0)