Skip to content

Unable to find Enum in Instance when Imported #857

@Werni2A

Description

@Werni2A

I'm not sure whether this is the right repository or not, feel free to move the issue.

Enums don't work when they are used under the condition, that they are

  • used in an instance and
  • are imported from another ksy-file.

I run Kaitai Struct locally in its WebIDE with latest commit 3a8cbe0d50596546fc05946bb27c6a04ec404ce9.

See the following example which produces the error message for bar while foo works fine.

Parse error: undefined
Call stack: undefined io.kaitai.struct.precompile.ErrorInInput: (main): /types/bar/instances/get_some_value/value: unable to find enum 'my_enum::foo', searching from repreoducer::bar

My current workaround is to define the enum inside reproducer.ksy then it works fine.

reproducer.ksy

meta:
  id: repreoducer
  file-extension: repreoducer
  endian: le
  imports: my_enum
  
types:

  foo:
    seq:
      - id: bitmap
        type: u2
        enum: my_enum::foo

  bar:
    seq:
      - id: bitmap
        type: u2
    instances:
      get_some_value:
        value: bitmap & 0x03
        enum: my_enum::foo

my_enum.ksy

meta:
  id: my_enum
  file-extension: my_enum

enums:
  foo:
    0: test0
    1: test1

This might be related to #651 but it seems like this bug has already been fixed, at least my type foo works without any problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions