Skip to content

API/Literal: closed-world rfl::Literal forces abandoning it across 15 extensible LSP string-enum types (*Options + std::string + .from_name<...>().str()) #181

Not planned

Description

@clockblocker

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

Related issues

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

LSP defines numerous "open/extensible string enum" types where the specification lists well-known predefined values while explicitly allowing clients to send custom extension strings (e.g. CodeActionKind "refactor.move", FoldingRangeKind "custom.region", SemanticTokenTypes, LanguageKind, etc.).

Because rfl::Literal<...> is strictly closed-world and rejects any string outside its compile-time list, slang-server had to rip rfl::Literal out of 15 LSP wire types in commit 1e371b7 (PR #417: "LSP: Relax rfl::Literal types to string"), replacing every wire field with bare std::string while keeping a parallel *Options = rfl::Literal<...> shadow alias solely for compile-time-checked string construction:

  • include/lsp/LspTypes.h#L273-L278:
    /// A set of predefined code action kinds. The LSP code action kind namespace is open ended,
    /// so clients can advertise and request extension kinds outside this predefined set.
    using CodeActionKindOptions = rfl::Literal<"", "quickfix", "refactor", "refactor.extract",
                                               "refactor.inline", "refactor.rewrite", "source",
                                               "source.organizeImports", "source.fixAll", "notebook">;
    using CodeActionKind = std::string;
  • Same split repeated across 14 additional types in include/lsp/LspTypes.h: FileOperationPatternKind (#L254-L255), MarkupKind (#L372-L373), FoldingRangeKind (#L384-L385), TokenFormat (#L508-L509), ResourceOperationKind (#L537-L538), LanguageKind (#L609-L618), FailureHandlingKind (#L632-L634), PositionEncodingKind (#L1337-L1338), TraceValue (#L2801-L2802), UniquenessLevel (#L3724-L3725), MonikerKind (#L4146-L4147), SemanticTokenTypes (#L6642-L6647), SemanticTokenModifiers (#L6654-L6657), and DocumentDiagnosticReportKind (#L6847-L6848).
  • Call sites must convert through the shadow *Options alias on every construction/comparison:

Root Cause & Suggested Direction

rfl::Literal<...> only models closed string enumerations; reflect-cpp has no open/extensible literal vocabulary type (analogous to TypeScript's "quickfix" | (string & {}) or JSON Schema anyOf: [{enum: [...]}, {type: "string"}]) that preserves compile-time-checked known values and schema hints while accepting unknown extension strings on parse.

Consider an open-enum / extensible-literal type or rfl::Variant<rfl::Literal<...>, std::string> ergonomics helper (with compile-time make<"known">() construction, direct string comparison, and clean JSON Schema emission) so protocol consumers do not have to split every extensible string enum into *Options + std::string.

Activity

  1. added
    known-downstream-workarounds
    on Nov 29, 2026
  2. changed the title [-]API/Literal (slang-server): closed-world rfl::Literal forces abandoning it across 15 extensible LSP string-enum types (*Options + std::string + .from_name<...>().str())[/-] [+]API/Literal: closed-world rfl::Literal forces abandoning it across 15 extensible LSP string-enum types (*Options + std::string + .from_name<...>().str())[/+] on Nov 29, 2026
  3. added
    wontfix
    on Nov 29, 2026
  4. clockblocker commented on Nov 29, 2026

    @clockblocker
    OwnerAuthor

    Triage decision: closing as wontfix (not planned) for the upstream adoption track.

    Rationale: Making rfl::Literal open/extensible for LSP string enums is a single-repo convenience (slang-server) where std::string + named constants already works cleanly without weakening rfl::Literal's closed-world compile-time contract. Zero external adoption leverage.

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-workaroundswontfix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions