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

@main shouldn't allow @available #67136

Open
KeithBauerANZ opened this issue Jul 5, 2023 · 0 comments
Open

@main shouldn't allow @available #67136

KeithBauerANZ opened this issue Jul 5, 2023 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@KeithBauerANZ
Copy link

Description

Like the soundness hole with stored properties and @available fixed in Swift 5.9, there's a similar hole with @main:

@main
@available(macOS 99, *)
struct Main {
    static func main() {
        print("oops")
    }
}

(on macOS:)

swiftc -parse-as-library available-main.swift && ./available-main
oops

This can allow code explicitly requiring a newer OS to be run on an older OS.

Either mixing @main with @available should be disallowed, or the availability information should be forwarded to the linker.

Environment

swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0

and

swift-driver version: 1.85 Apple Swift version 5.9 (swiftlang-5.9.0.120.7 clang-1500.0.34.3)
Target: arm64-apple-macosx13.0

show the same behavior.

@KeithBauerANZ KeithBauerANZ added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant