title: Value assigned to primitive will be lost
body: <p>If I have an array of objects, and loop through them assigning a value to an attribute for each one, WebStorm warns me:</p>
  
  <blockquote>
    <p>Values assigned to primitive will be lost</p>
  </blockquote>
  
  <p>However, when testing in the console, I do not "lose" any values.</p>
  
  <p>This only happens when the loop is inside of a function.</p>
  
  <p>An example of this error below:</p>
  
  <pre><code>let people = [
      {
          name: 'Foo',
          age: 21,
          surname: 'FooBar'
      },
  
      {
          name: 'Bar',
          age: 51,
          surname: 'FooBar'
      }
  ];
  </code></pre>
  
  <p>Without function wrapper:</p>
  
  <pre><code>people.forEach(function (person) {
      person.surname = 'Baz'; // No error. Works in console.
  });
  </code></pre>
  
  <p>With function wrapper:</p>
  
  <pre><code>function changeSurname(people) {
      people.forEach(function (person) {
          person.surname = 'Baz'; // Error warning me that value assigned to primitive will be lost.
      });
  }
  
  changeSurname(people);
  </code></pre>
  
  <p>Both of these produce the same output in the console (the surname is changed to 'baz').</p>
  
  <p>I assume this has something to do with the object reference and what <code>person</code> points to, but I am not sure exactly what.</p>
  
  <p>Why do I see this error?</p>
  
  <p>What potential bug is WebStorm trying to save me from?</p>