JavaScript and other backends cannot use _index in pos for repeated instances
The docs give an [example](https://doc.kaitai.io/user_guide.html#repeat-index) of parsing a file format that contains a table of offsets using repeated instances:

~~~yaml
meta:
  id: test
  file-extension: test
seq:
  - id: num_files
    type: u4
  - id: len_files
    type: u4
    repeat: expr
    repeat-expr: num_files
  - id: ofs_files
    type: u4
    repeat: expr
    repeat-expr: num_files
instances:
  file_bodies:
    pos: ofs_files[_index]
    size: len_files[_index]
    repeat: expr
    repeat-expr: num_files
~~~

(I'm using the second example from that section, with a `meta` section added and the unnecessary `file_names` section removed for brevity)

If we compile this example to JavaScript using Kaitai compiler 0.8-SNAPSHOT337369088 (I'm using the Web IDE), we get this:

~~~javascript
  Object.defineProperty(Test.prototype, 'fileBodies', {
    get: function() {
      if (this._m_fileBodies !== undefined)
        return this._m_fileBodies;
      var _pos = this._io.pos;
      this._io.seek(this.ofsFiles[i]); // !!!
      this._m_fileBodies = new Array(this.numFiles);
      for (var i = 0; i < this.numFiles; i++) {
        this._m_fileBodies[i] = this._io.readBytes(this.lenFiles[i]);
      }
      this._io.seek(_pos);
      return this._m_fileBodies;
    }
  });
~~~

Notice how, on the line I marked with a comment, the code is trying to use variable `i` before it is defined. So the code crashes when trying to actually parse any files.

The same problem appears in the Python backend, and possibly in others.

I believe it should be possible to fix this simply by moving the marked line into the body of the for loop.