Skip to content

rfl::TaggedUnion: fix move-only / rfl::Box<T> rejection in ParserTaggedUnion::wrap_if_necessary #114

Done

Description

@clockblocker

Bug

rfl::parsing::ParserTaggedUnion::wrap_if_necessary (include/rfl/parsing/ParserTaggedUnion.hpp:296-299) returns _val by value (return _val;) when the alternative type already contains the inline _discriminator field. Even though write_wrapped (lines 280-285) avoids calling wrap_if_necessary on write, wrap_if_necessary is still instantiated in decltype(wrap_if_necessary<...>(std::declval<...>())) (e.g., lines 135 and 218), causing compilation failure for any move-only alternative — including rfl::Box<T> and structs containing rfl::Box<T> or std::unique_ptr<T>.

Evidence

  • Surfaced in clockblocker/solidity#3 (Yul AST recursive TaggedUnion alternatives containing move-only rfl::Box<T>).
  • Root-cause site on showcase/all-lanes: include/rfl/parsing/ParserTaggedUnion.hpp:296-299 (and decltype call sites at lines 135, 218).

Acceptance Criteria

  • Fix ParserTaggedUnion::wrap_if_necessary (e.g., return const T& via decltype(auto) or avoid copying _val in the inline-discriminator branch, and ensure decltype / type-query callers strip references cleanly) so move-only alternatives (rfl::Box<T>, structs holding rfl::Box<T> / std::unique_ptr<T>) with inline discriminator fields compile and serialize/deserialize cleanly.
  • Add regression tests covering rfl::TaggedUnion with move-only alternatives (both rfl::Box<T> fields and inline discriminator structs) across read, write, and rfl::json::to_schema.

Activity

  1. added
    bug
    ready-for-agent
    on Nov 27, 2026
  2. added 2 commits that reference this issue on Nov 27, 2026
  3. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Resolved on showcase/all-lanes via Batch 1 merge 4861aafd (commits d4700190, d3673b24). Verified with 962/962 CTest passing under AppleClang 17 -Wall -Werror + REFLECTCPP_STRICT_WARNINGS=ON (non-SYSTEM -I for internal tests, -isystem for downstream consumers) and dual Judge approval (Gemini 4 Neon High: APPROVE WITH NITS, all addressed; Claude Opus 5.5 High re-check: APPROVE).

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

    bugready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions