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

#function behavior differs based on initializer implementation #79663

Open
nh7a opened this issue Feb 27, 2025 · 0 comments
Open

#function behavior differs based on initializer implementation #79663

nh7a opened this issue Feb 27, 2025 · 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

@nh7a
Copy link

nh7a commented Feb 27, 2025

Description

I've noticed that the behavior of #function at the type level varies depending on whether the initializer is explicitly implemented or synthesized.

Also, when #function is used with a mutable ivar, it behaves the same as in the S2 case.

Reproduction

struct S1 {
    let name = #function  // "init(int:)"
    var int: Int
}

struct S2 {
    let name = #function  // "S2"
    var int: Int
    init(int: Int) {
        self.int = int
    }
}

struct S3 {
    var name = #function  // "S3"
    var int: Int
}

Expected behavior

#function gets resolved consistently regardless of whether the initializer is explicitly implemented or synthesized.

Environment

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0

Additional information

No response

@nh7a nh7a added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Feb 27, 2025
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