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-15277] -experimental-skip-non-inlinable-function-bodies-without-types can yield spurious availability errors #57599

Open
swift-ci opened this issue Oct 4, 2021 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 4, 2021

Previous ID SR-15277
Radar None
Original Reporter kenbongort (JIRA User)
Type Bug

Attachment: Download

Environment

Mac OS 11.5.2

Xcode 13.0 (13A233)

Swift 5.5 (swift-5.5-RELEASE)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 5964d985162594057b7ed12a23b3d304

Issue Description:

Calling swift-frontend with -experimental-skip-non-inlinable-function-bodies-without-types throws up errors when compiling this code:

import os.log

@inlinable public func os_log() {
    if #available(macOS 10.14, iOS 12, tvOS 12, watchOS 5, *) {
      os.os_log(.debug, log: .default, "Hello")
    }
}

The errors are:

/Users/kennethbongort/Source/swift-build-test/Sources/swift-build-test/main.swift:13:10: error: 'os_log(_:dso:log:_:_:)' is only available in macOS 10.14 or newer
      os.os_log(.debug, log: .default, "Hello")
         ^
/Users/kennethbongort/Source/swift-build-test/Sources/swift-build-test/main.swift:13:10: note: add 'if #available' version check
      os.os_log(.debug, log: .default, "Hello")
         ^
/Users/kennethbongort/Source/swift-build-test/Sources/swift-build-test/main.swift:11:24: note: add @available attribute to enclosing global function
@inlinable public func os_log() {
                       ^
/Users/kennethbongort/Source/swift-build-test/Sources/swift-build-test/main.swift:13:18: error: 'debug' is only available in macOS 10.12 or newer
      os.os_log(.debug, log: .default, "Hello")
                 ^
/Users/kennethbongort/Source/swift-build-test/Sources/swift-build-test/main.swift:13:18: note: add 'if #available' version check
      os.os_log(.debug, log: .default, "Hello")
                 ^
/Users/kennethbongort/Source/swift-build-test/Sources/swift-build-test/main.swift:11:24: note: add @available attribute to enclosing global function
@inlinable public func os_log() {
                       ^
/Users/kennethbongort/Source/swift-build-test/Sources/swift-build-test/main.swift:13:31: error: 'default' is only available in macOS 10.12 or newer
      os.os_log(.debug, log: .default, "Hello")
                              ^
/Users/kennethbongort/Source/swift-build-test/Sources/swift-build-test/main.swift:13:31: note: add 'if #available' version check
      os.os_log(.debug, log: .default, "Hello")
                              ^
/Users/kennethbongort/Source/swift-build-test/Sources/swift-build-test/main.swift:11:24: note: add @available attribute to enclosing global function
@inlinable public func os_log() {

A small SwiftPM project is attached with code that demonstrates this issue. When I run the following swift-frontend command line, I get the errors described above:

/Library/Developer/Toolchains/swift-5.5-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Users/kennethbongort/Source/swift-build-test/Sources/swift-build-test/main.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -I /Users/kennethbongort/Source/swift-build-test/.build/x86_64-apple-macosx/debug -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -module-cache-path /Users/kennethbongort/Source/swift-build-test/.build/x86_64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -entry-point-function-name swift_build_test_main -resource-dir /Library/Developer/Toolchains/swift-5.5-RELEASE.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -module-name swift_build_test -target-sdk-version 11.3.0 -emit-module-doc-path /Users/kennethbongort/Source/swift-build-test/.build/x86_64-apple-macosx/debug/swift_build_test.swiftdoc -emit-module-source-info-path /Users/kennethbongort/Source/swift-build-test/.build/x86_64-apple-macosx/debug/swift_build_test.swiftsourceinfo -o /Users/kennethbongort/Source/swift-build-test/.build/x86_64-apple-macosx/debug/swift_build_test.swiftmodule

The same command line succeeds when the -experimental-skip-non-inlinable-function-bodies-without-types argument is removed.

@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
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