Skip to content

API/Enums: call-site-only rfl::UnderlyingEnums forces 40+ repetitions and causes mixed wire encodings for the same enum #183

Backlog

Description

@clockblocker

Part of #138
Popularity: 1/7 corpus consumers (slang-server)

Related issues

Observed Downstream Workaround (hudson-trading/slang-server @ 1b413a46)

slang-server uses integer-encoded enums for LSP wire types (e.g. MessageType, DiagnosticSeverity, CompletionItemKind, FileChangeType) and string-encoded enums for user-facing JSON config (Config::HoverConfig::DocCommentFormat).

Because reflect-cpp only offers rfl::UnderlyingEnums as a call-site processor (not a per-enum opt-in trait like rfl::config::enum_descriptions<E>), slang-server must thread <rfl::UnderlyingEnums> through 40+ separate read/write/to_generic/from_generic call sites:

Concrete wire-encoding drift caused by call-site-only control:

  • In include/SlangLspClient.h#L124-L170, the exact same InteractionSource enum and ActivateInstanceParams struct are serialized as a string in onActiveInstanceChanged (#L125: rfl::to_generic(params)) and in QuickPickParams::interactionSource (#L165: passArgs(...) -> rfl::to_generic(...)), yet serialized as an integer in makeActivateInstanceCommand (#L135) and QuickPickItem::value (#L154: rfl::to_generic<rfl::UnderlyingEnums>(ActivateInstanceParams{...})) — forcing tests (tests/cpp/CodeLensTests.cpp#L536-L551) to decode the outer QuickPickParams without UnderlyingEnums and its nested items[1].value with UnderlyingEnums.
  • Similarly, include/lsp/LspServer.h#L45 decodes command params with rfl::from_generic<P, rfl::UnderlyingEnums> while #L68 encodes command results with plain rfl::to_generic(result).

Root Cause & Suggested Direction

Enum wire representation (string vs underlying integer) is almost always an intrinsic property of the enum type / protocol schema, not a per-call-site whim. Because reflect-cpp only provides a call-site processor (rfl::UnderlyingEnums), mixed-protocol codebases must manually remember the processor at every serialization boundary and cannot compose an integer-encoded enum with a string-encoded enum in the same object without writing custom Reflector<E> boilerplate.

Provide a lightweight per-enum opt-in trait (e.g., rfl::config::underlying_enum<E> = true alongside rfl::config::enum_descriptions<E>, or an enum wire-format policy trait unified with #101).

Upstream Overlap

Activity

  1. added
    known-downstream-workarounds
    on Nov 29, 2026
  2. changed the title [-]API/Enums (slang-server): call-site-only rfl::UnderlyingEnums forces 40+ repetitions and causes mixed wire encodings for the same enum[/-] [+]API/Enums: call-site-only rfl::UnderlyingEnums forces 40+ repetitions and causes mixed wire encodings for the same enum[/+] on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    known-downstream-workarounds

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions