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

enum directive ignored in params list #413

Closed
webbnh opened this issue Apr 9, 2018 · 12 comments
Closed

enum directive ignored in params list #413

webbnh opened this issue Apr 9, 2018 · 12 comments
Milestone

Comments

@webbnh
Copy link

webbnh commented Apr 9, 2018

type:
  # ...
  payload:
    params:
    - id: rec_type
      enum: rec_types
      type: u1
    seq:
    - id: data
      #process: xor(0)
      type:
        cases:
          rec_types::type_1: type_1
          rec_types::type_2: type_2
        switch-on: rec_type

Produces errors, such as:

/types/payload/seq/0/type/cases/EnumByLabel(identifier(rec_types),identifier(type_2)): can't compare Int1Type(false) and EnumType(List(rec_types),CalcIntType)

(See Lobby discussion.)

@GreyCat
Copy link
Member

GreyCat commented Apr 9, 2018

Ok, just for clarity, this seems to be caused not by type switching, so basically anything like that should reproduce the bug:

meta:
  id: params_enum
enums:
  animals:
    1: cat
    2: dog
seq:
  - id: one
    type: u1
    enum: animal
  - id: invoke_with_param
    type: with_param(one)
types:
  with_param:
    params:
      - id: enumerated_one
        type: u1
        enum: animal
    instances:
      is_cat:
        value: enumerated_one == animals::cat # would break if there's a bug

@zolo
Copy link

zolo commented Oct 18, 2018

I'd like to see enum param support as well. A workaround is to pass ints and cast the cases using to_i

@GreyCat
Copy link
Member

GreyCat commented Oct 22, 2018

Actually, I've just checked, support for enums in params was implemented ages ago: kaitai-io/kaitai_struct_compiler@41e9a06

I've just added test to confirm that — see ParamsEnum: http://kaitai.io/ci/

@GreyCat GreyCat added this to the v0.9 milestone Oct 22, 2018
@KOLANICH
Copy link

Have just checked on the latest ver from appveyor, doesn't work on this file: https://github.com/KOLANICH/kaitai_struct_formats/blob/mdt/scientific/nt_mdt/nt_mdt.ksy#L89

@GreyCat
Copy link
Member

GreyCat commented Oct 24, 2018

Thanks, caught yet another problem ;) New version should be available in ~15 minutes, please try again?

@KOLANICH
Copy link

Still fails. Could you test on the spec I have referenced?

@GreyCat
Copy link
Member

GreyCat commented Oct 25, 2018

That exact spec you're referring to is obviously broken, at least in respect supplying "type" as enum, and then switching over it as it was an integer. Here's a slightly fixed version that I was testing upon: https://gist.github.com/GreyCat/e99663ca7cbc31300c07ddea9352677d

If you're still getting an error, please state (1) which .ksy file exactly you're using, (2) what error you're getting.

@GreyCat
Copy link
Member

GreyCat commented Nov 25, 2018

No replied for 1 month, from my perspective everything was fixed. Closing for now, please feel free to reopen if you still have repro.

@GreyCat GreyCat closed this as completed Nov 25, 2018
@KOLANICH
Copy link

Here's a slightly fixed version that I was testing upon: https://gist.github.com/GreyCat/e99663ca7cbc31300c07ddea9352677d

That works, thank you.

@hakanai
Copy link

hakanai commented Jul 11, 2019

I see this issue both on https://ide.kaitai.io/ and on https://ide.kaitai.io/devel right now. Same workaround of adding .to_i fixes it for me. It's quite possible that the deployed versions are out of date, but exactly how out of date?

@GreyCat
Copy link
Member

GreyCat commented Jul 11, 2019

@trejkaz Unfortunately:

  1. IDE deployment is broken now :( You can see deployed versions in about box.
  2. We never had automated deployment of new versions of compiler.
  3. Publications of JS versions of compiler to npmjs is broken as well :(

@hakanai
Copy link

hakanai commented Jul 15, 2019

Hmm, so what's the path right now for getting a working IDE of some sort to work with KTS files? I had planned to some day make my hex viewer able to deal with them but it's probably a lot of work to get that up and going.

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

4 participants