title: Why does a second @State variable crash my program in SwiftUI
body: <pre><code>import SwiftUI
  import CoreData
  
  
  struct AddTaskView: View {
      
      @Environment(\.managedObjectContext) private var viewContext
      @Environment(\.presentationMode) var presentationMode
      
      @FetchRequest(entity: Task.entity(), sortDescriptors: [])
      var tasks: FetchedResults&lt;Task&gt;
      
      @FetchRequest(entity: DailyScore.entity(), sortDescriptors: [NSSortDescriptor(key: &quot;date&quot;, ascending: false)])
      var scores: FetchedResults&lt;DailyScore&gt;
      
      let types = [&quot;Exercise&quot;, &quot;German&quot;, &quot;Cold Shower&quot;, &quot;Fast Food&quot;]
      
      @State var selectedTaskIndex = 0
      @State var newType = &quot;&quot;
      
      var body: some View {
  </code></pre>
  <p>I can't figure out why <code>@State var newType = &quot;&quot;</code> causes the program to crash. (and it is independent of usage, so that is irrelevant as far as I'm aware)</p>