Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a number of errors in loops #308

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

Mingun
Copy link
Contributor

@Mingun Mingun commented Sep 15, 2024

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:

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.

Mingun and others added 17 commits September 15, 2024 20:42
… `SwitchIfOps.switchCases`

PerlCompiler implements SwitchIfOps so this call already was performed
…d here

If that not the case, then a bug in compiler is present.
Exception is better rather than generating incorrect code
…e it only can be used

We do not want that type validation calculate type of actually undefined variable
Previous behavior (everything with 1 in last column was fixed):

|Language|Initial|Incremented|`_index` of first iteration
|--------|-------|-----------|---------------------------
|C++     |0      |before     |1
|C#      |0      |before     |1
|Go      |1      |after      |1
|Java    |0      |before     |1
|JS      |0      |before     |1
|Lua     |0      |after      |0
|Nim     |0?     |after      |0 (variable declared without initializer)
|Perl    |-      |-          |- (variable was not declared)
|PHP     |0      |before     |1
|Python  |0      |after      |0
|Ruby    |0      |before     |1
|Rust    |0      |before     |1

Fixes kaitai-io/kaitai_struct#958
…ndRepeatExprHeader` and `condRepeatExprFooter`
…dRepeatEosHeader` and `condRepeatEosFooter`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent compiler generated code when 'repition index' is used in 'repeat-until' expression
1 participant