Skip to content

[SR-580] False negative in "variable was never mutated" #43197

@gribozavr

Description

@gribozavr
Previous ID SR-580
Radar None
Original Reporter @gribozavr
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee None
Priority Medium

md5: 49666d7f896eca11031f8c6971fb6cb6

Issue Description:

This code should produce a warning "variable 'result' was never mutated".

func foo(x: Int) -> Int {
  var result = x + 1
#if NOT_ENABLED
  _ = result
#endif
  return result
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions