Skip to content

Enum assignment fails on list of enums #374

@rafa-be

Description

@rafa-be

Assigning an Enum with its value fails when the enum is declared within a List:

Schema:

enum Status {
  active @0;
  inactive @1;
  pending @2;
}

struct Container {
    statuses @0 :List(Status);
}

When running this Python code (PyCapnp v2.0.0):

msg = Container()

msg.init("statuses", 1)
msg.statuses[0] = Status.active

This exception gets raised:

KjException: capnp/dynamic.c++:1827: failed: expected reader.type == ENUM [4 == 9]; Value type mismatch.

However, assigning a string value works as expected:

msg.statuses[0] = "active"

This behavior is odd, as assigning an Enum that is not declared within a List works perfectly:

Schema:

struct Container {
    status @0 :Status;
}

Python code:

msg = Container()
msg.status = Status.active

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions