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-13644] Conditional compilation breaks overload resolution #56080

Open
ffried opened this issue Oct 2, 2020 · 1 comment
Open

[SR-13644] Conditional compilation breaks overload resolution #56080

ffried opened this issue Oct 2, 2020 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@ffried
Copy link
Contributor

ffried commented Oct 2, 2020

Previous ID SR-13644
Radar rdar://problem/69882452
Original Reporter @ffried
Type Bug
Environment

Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)
Target: x86_64-apple-darwin19.6.0

(as included in Xcode 12.0.1)

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

md5: 0f8f5d009c6dcac8286d646e0608e871

Issue Description:

The following code chooses the wrong overload of function if DEBUG is defined.

func function(_: () -> ()) { print("NoParam") }
func function(_: (() -> ()) -> ()) { print("WithParam") }

#if DEBUG
print("DEBUG is set")
print("Expected: NoParam")
#else
print("DEBUG is not set")
print("Expected: WithParam")
#endif
print("Actual:   ", terminator: "")
function {
    #if !DEBUG
    $0()
    #endif
}

Given that DEBUG is set, there is actually no parameter used in function. Thus it should take the overload whose closure takes no parameter.

@typesanitizer
Copy link

@swift-ci create

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants