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

switches without nondefaults results in syntax error on Python #595

Closed
ejeandel opened this issue Jun 23, 2019 · 2 comments
Closed

switches without nondefaults results in syntax error on Python #595

ejeandel opened this issue Jun 23, 2019 · 2 comments
Assignees
Milestone

Comments

@ejeandel
Copy link

ejeandel commented Jun 23, 2019

The following codes produces a syntax error on python:

meta:
  id: ops
  endian: le
seq:      
  - id: opcode
    type: u1
  - id: arguments
    type:
      switch-on: opcode
      cases:
        _: u4

the produced code is:

    def _read(self):
        self.opcode = self._io.read_u1()
        _on = self.opcode
        else:
            self.arguments = self._io.read_u4le()

hence a "else" with no "if".
Maybe this particular pattern should not be allowed ?

@GreyCat
Copy link
Member

GreyCat commented Jun 23, 2019

Good catch, thanks! I don't see any problem with allowing that, so I'd rather fix the codegen.

@generalmimon generalmimon self-assigned this Feb 28, 2020
generalmimon added a commit to kaitai-io/kaitai_struct_tests that referenced this issue Feb 29, 2020
@generalmimon
Copy link
Member

Fixed in kaitai-io/kaitai_struct_compiler@5b1f73b (Lua, Perl & Python) and kaitai-io/kaitai_struct_compiler@5f9f400 (Ruby)

@GreyCat GreyCat added this to the v0.9 milestone May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants