Referencing _index in the pos attribute of a repeated instance produces: undefined local variable or method `i'
Here's about the simplest example of the problem I could come up with. This is almost verbatim the second example in [7.9. Repetition index](http://doc.kaitai.io/user_guide.html#repeat-index). I've just made things shorter by using `u1` instead of `u4`, and removing the `file_names` item.

`files.ksy`:

```ksy
meta:
  id: files
seq:
  - id: num_files
    type: u1
  - id: len_files
    type: u1
    repeat: expr
    repeat-expr: num_files
  - id: ofs_files
    type: u1
    repeat: expr
    repeat-expr: num_files
instances:
  file_bodies:
    pos: ofs_files[_index]
    size: len_files[_index]
    repeat: expr
    repeat-expr: num_files
```

And we want to use this on `files.bin`:

    00000000: 02 05 04 0a 13 00 00 00 00 00 61 62 63 64 65 00 | ..........abcde.
    00000010: 00 00 00 77 78 79 7a                            | ...wxyz

When you run `ksv files.bin files.ksy`, everything is initially fine. But when you try to expand the `file_bodies` node, you get:

```ruby
files.rb:42:in `file_bodies': undefined local variable or method `i' for Files(num_files=2 len_files=[5, 4] ofs_files=[10, 19]):Files (NameError)
```

If you compile to Ruby, it's obvious what's wrong:

```ruby
  def file_bodies
    return @file_bodies unless @file_bodies.nil?
    _pos = @_io.pos
    @_io.seek(ofs_files[i])
    @file_bodies = Array.new(num_files)
    (num_files).times { |i|
      @file_bodies[i] = @_io.read_bytes(len_files[i])
    }
    @_io.seek(_pos)
    @file_bodies
  end
```

It seems `ksc` interprets the `pos` attribute as outside of the repetition loop, when it should be inside. I've only looked at the Ruby, Java and CSharp output, but it seems to be doing this in all target languages.