kaitai_struct_compiler
kaitai_struct_compiler copied to clipboard
Fix a number of errors in loops
This PR the result of revision of how generation of repeated attributes is implemented due to which a number of bugs was found and fixed:
TypeValidatorincorrectly define_variable for all kinds of loops, but it is generated only forrepeat-untilloops- fixes https://github.com/kaitai-io/kaitai_struct/issues/958, closes #245
- C#, Go, Java, JavaScript was calculate count of repetitions of
repeat-exprloops on each iteration, whereas other languages performs such calculations only once. Now they are also calculate count only once - Now Perl defines
_indexvariable inrepeat: eosloops - Go and Rust was incorrectly used root IO object instead of current IO object of the attribute. The difference should be noticable when
io: ...is used
This PR supersedes #234
Also, some refactoring was done: removed unused parameters and documented methods that generates loops.
Besides, _currentIteratorType was renamed to _lastParsedType (this is the variable that holds type of the _ variable in expression language) because it is used also in valid: expr key to refer to the element that just was parsed.
Thank you for fixing this and closing the PR. I apologize for not following up on my PR last year. I'm happy we have this consistent behavior across languages.