Skip to content

Add format-agnostic rfl::ErrorKind to rfl::ErrorDetail - #70

Open
clockblocker wants to merge 3 commits into
mainfrom
error-kind
Open

clockblocker wants to merge 3 commits into
mainfrom
error-kind

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds format-agnostic rfl::ErrorKind (enum class ErrorKind : std::uint8_t, 10 frozen values) directly on rfl::Error and rfl::ErrorDetail, cleanly targeting main with zero YAML/CLI/TOML coupling.

Frozen 10-Value Taxonomy

other, io_error, syntax_error, missing_field, unknown_field, duplicate_field, invalid_length, invalid_type, invalid_value, constraint_violation

Key Design & ABI / Compatibility Notes

  • Inline zero-alloc storage: Error::kind_ is stored inline on rfl::Error (sizeof(rfl::Error): 32B -> 40B, +8B due to pointer alignment) so single-error paths (including std::variant backtracking) perform zero heap allocations for ErrorDetail unless explicitly nested.
  • Variant-heavy JSON read microbenchmark (50,000 reads of 4-alternative std::variant<A, B, C, D>, AppleClang -O2):
    • Failing/backtracking reads: main ~358–373 ms vs #70 ~362–366 ms (parity; zero heap-alloc penalty).
    • Matching 4th-alternative reads: main ~211 ms vs #70 ~219–225 ms.
  • ErrorDetail::operator==: Now compares kind alongside path and message (note for callers comparing ErrorDetail instances directly).
  • Reconciled dual-model review fixes (37ae45b0):
    1. Fixed FieldVariantReader error path to include the matched discriminator key (["circle", "radius"]).
    2. Removed other -> invalid_value fallback in ParserTaggedUnion::get_discriminator so untagged formats preserve other.
    3. Aligned NoFieldNames overflow in ViewReaderWithStrippedFieldNames / ViewReaderWithDefaultAndStrippedFieldNames to ErrorKind::invalid_length.
    4. Tagged Timestamp::from_string (+ Timestamp::from_reflection + HasFromReflectionMethod supporting Result<T>) and ParserWString invalid UTF-8 as ErrorKind::invalid_value.
    5. Updated Validator::wrap_validated to tag errors in-place on failure (avoiding an extra move on success) and removed stale NoDuplicateKeys doc reference.

Verification

  • Full JSON + Generic + Env + targeted suites pass under -Wall -Werror (44/44 targeted tests after final fixes; 591/591 full suite on 1d65dc8d).

@clockblocker
clockblocker changed the base branch from yaml-source-map to main November 27, 2026 08:44
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