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-13500] [AutoDiff] Error on lack of @usableFromInline on internal @derivative only shown in release builds #55942

Closed
rxwei opened this issue Sep 4, 2020 · 3 comments
Assignees
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@rxwei
Copy link
Member

rxwei commented Sep 4, 2020

Previous ID SR-13500
Radar rdar://problem/68336300
Original Reporter @rxwei
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, AutoDiff
Assignee @rxwei
Priority Medium

md5: e31be676d7860a84a592e19e506e2ee8

Issue Description:

The following code should cause the type checker to emit an error saying the derivative function is missing @usableFromInline.

Reproducer:

import _Differentiation

public func foo(x: Float) -> Float {
    x
}

@derivative(of: foo)
func fooVJP(x: Float) -> (value: Float, pullback: (Float) -> Float) {
    return (x, { $0 })
}

Current behavior:
If you build it with `swiftc`, the error is correctly produced.
If you build it inside a Swift package with `swift build` (debug configuration), it will build successfully. This is not the right behavior.
If you build it inside a Swift package with `swift build -c release`, it will produce the error as expected.

This is a serious issue that could cause a lot of linker errors on undefined symbols to slip through.

@rxwei
Copy link
Member Author

rxwei commented Sep 4, 2020

@swift-ci create

@rxwei
Copy link
Member Author

rxwei commented Sep 4, 2020

Turns out the @derivative type checking logic doesn't respect -enable-testing. Internal declarations in debug SwiftPM builds are treated as effectively public.

@rxwei
Copy link
Member Author

rxwei commented Sep 4, 2020

#33800

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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