Uploaded image for project: 'Swift'
  1. Swift
  2. SR-1658

No warning for unmodified var on two paths

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:

      Description

      func test() {
        var x: Int
        if Int("abc") == nil {
          x = 1
        } else {
          x = 2
        }
        print(x)
      }
      

      This contrived example ought to give us a warning to change the var back into a let. Unfortunately, as a path-sensitive check this isn't quite trivial.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jrose Jordan Rose
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: