Skip to content

Fix enum support in nested containers and tables#45

Open
jglanz wants to merge 1 commit intomasterfrom
fix/enum-support-nested-types-and-containers
Open

Fix enum support in nested containers and tables#45
jglanz wants to merge 1 commit intomasterfrom
fix/enum-support-nested-types-and-containers

Conversation

@jglanz
Copy link
Copy Markdown
Collaborator

@jglanz jglanz commented Mar 29, 2026

Change Description

This PR resolves an issue where enums used within nested containers and tables (e.g., std::pair<>, std::vector<>) would cause a CDT_INTERNAL_ERROR. The fix introduces proper handling for enums within these contexts:

  • Updated abigen.hpp to register enums and retrieve their base type names.
  • Updated gen.hpp to return the base type names for enums.
  • Added new tests (abigen_test_enum_table.cpp and .json) to cover use cases like enums as direct table fields and enums inside nested containers.

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

wire-cdt changes (2 files + 2 test files)

  Bug: adding_explicit_nested_dispatcher (abigen.hpp) and translating_explicit_nested_dispatcher (gen.hpp) handled builtins,
  aliases, templates, and records as inner types of nested containers — but had no case for enums. When an enum appeared inside
  std::pair<>, std::vector<>, etc. in a table struct, it hit CDT_INTERNAL_ERROR.

  Fix:
  - plugins/sysio/abigen.hpp:316-318 — Added isEnumeralType() branch that calls add_type() (to register the enum in _abi.enums)
  and returns get_base_type_name() as the type name
  - plugins/sysio/gen.hpp:547-548 — Added isEnumeralType() branch that returns get_base_type_name() as the type name
  - New test: abigen_test_enum_table.cpp / .json — covers enums as direct table fields, enums inside std::vector<std::pair<enum,
   T>>, both enum and enum class
@jglanz jglanz requested a review from heifner March 29, 2026 12:25
@jglanz jglanz self-assigned this Mar 29, 2026
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.

1 participant