Skip to content

Add opt-in rfl::NoDuplicateKeys processor for YAML duplicate mapping keys - #44

Closed
clockblocker wants to merge 1 commit into
wave-base-14from
yaml-no-duplicate-keys
Closed

clockblocker wants to merge 1 commit into
wave-base-14from
yaml-no-duplicate-keys

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Part 3 of 4 (split from #40; stacked on #43).

Summary

  • Keeps existing default duplicate-key behavior unchanged for backwards compatibility.
  • Adds an opt-in rfl::NoDuplicateKeys processor (include/rfl/NoDuplicateKeys.hpp, include/rfl/internal/no_duplicate_keys_v.hpp), matching rfl::NoExtraFields and rfl::EnumNamesOnly.
  • Enforces compile-time safety via reader_supports_no_duplicate_keys_v<R> (static_assert in Parser::read, ViewReader, ViewReaderWithDefault, MapReader, and FieldVariantReader) so passing rfl::NoDuplicateKeys to a reader that does not implement duplicate-key detection fails at compile time rather than silently succeeding.
  • When rfl::NoDuplicateKeys is passed to rfl::yaml::read, rfl::yaml::Reader::read_object rejects repeated mapping keys with Duplicate key '<k>'. at the repeated key's source location, aggregated alongside other field errors via add_error() (and honoring rfl::FailFast).
  • Documents rfl::NoDuplicateKeys in docs/content/processors.md and docs/content/supported_formats/yaml.md, and adds tests in tests/yaml/test_no_duplicate_keys.cpp.

Verification

  • Verified rfl::json::read<S, rfl::NoDuplicateKeys> fails to compile with rfl::NoDuplicateKeys is not supported by this reader.
  • Verified full shared-library CMake suite (631/631 passed) plus C++20/C++23 header checks.

…keys

Keep existing default duplicate-key behavior intact for backwards
compatibility, and add an opt-in rfl::NoDuplicateKeys processor (matching
rfl::NoExtraFields and rfl::EnumNamesOnly).

When rfl::NoDuplicateKeys is passed, rfl::yaml::Reader::read_object tracks
seen keys per mapping and reports each repeated key as
"Duplicate key '<k>'." at the repeated key's source location, aggregated
alongside other field errors via add_error() (and honoring rfl::FailFast).
@clockblocker

Copy link
Copy Markdown
Owner Author

Branch is preserved on fork and showcase/all-lanes (d0f1fca1) as a reference artifact and parked in #117 (Moonshots & Possible Scope Creep).

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