Skip to content

[6.1 regression]: #if directives may suppress some warning emissions #86059

@jamieQ

Description

@jamieQ

Description

No response

Reproduction

func f() {
    // expected unused variable warning
    var x = 0   // ⚠️ initialization of variable 'x' was never used; consider replacing with assignment to '_' or removing it
}

func g() {
    // no unused variable warnings produced
    #if true
    var x = 0   // ❓no warning – unexpected
    #else
    var x = 0   // no warning – expected
    #endif
}

Expected behavior

warnings in the evaluated conditional compilation branches should still be produced

Environment

Swift version 6.3-dev (LLVM cff341857efbfc7, Swift 956dc0c)
Target: x86_64-unknown-linux-gnu

Additional information

i didn't go back in history too far, but the issue affecting the repro appears to have started in the 6.1 release.
godbolt: https://swift.godbolt.org/z/9oebPGoo1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions