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

Need better diagnostics for multi-value assignment with missing parens

    XMLWordPrintable

    Details

      Description

      Given var a = 1, b = 2, in some other languages you can swap them with

      a, b = b, a

      In Swift, parens are required:

      (a, b) = (b, a)

      If you forget the parens, though, the errors aren't very helpful:

      Consecutive statements on a line must be separated by ';'
      Expected expression
      
      a, b = b, a
       ~
       ;

      It'd be nice to recognize this and suggest adding parentheses.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jtbandes Jacob Bandes-Storch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: