Xcode-beta (7A165t): Show warning if & pattern matching creates unreachable statements

Originator:robert.vojta
Number:rdar://21960685 Date Originated:23-Jul-2015 03:45 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A165t)
Classification:Enhancement Reproducible:Always
 
Try to compile following code:

  if case number = 2, case number =3 {
    // unreachable
  }

It’s compilable, no warning. When I look at assembly, it’s transformed to:

  if number == 2 && number == 3 {
    // unreachable as well
  }

I would expect warning that the Code will never be executed. Something like switch has for enums:

  enum A {
    case A1
  }

  let a = A.A1

  switch a {
    case .A1:
      break
    default:         <- Warning: Default will never be executed
      print("a")
  }

See discussion at: http://stackoverflow.com/a/31515972/581190

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!