Repository navigation
Read structs with defaults that hold a Validator without a valid default - #780
Closed
clockblocker wants to merge 1 commit into
Closed
clockblocker wants to merge 1 commit into
clockblocker wants to merge 1 commit into
Conversation
clockblocker
force-pushed
the
fix-700-deferred-defaults
branch
from
November 14, 2026 03:25
4c04f88 to
bf178ee
Compare
This was referenced Nov 14, 2026
Open
clockblocker
marked this pull request as draft
November 15, 2026 07:42
clockblocker
force-pushed
the
fix-700-deferred-defaults
branch
from
November 16, 2026 05:18
bf178ee to
9fa1d1d
Compare
clockblocker
force-pushed
the
fix-700-deferred-defaults
branch
2 times, most recently
from
November 22, 2026 20:20
2d33403 to
64c847f
Compare
clockblocker
marked this pull request as ready for review
November 23, 2026 01:39
clockblocker
force-pushed
the
fix-700-deferred-defaults
branch
from
November 23, 2026 03:15
64c847f to
0122865
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clockblocker
force-pushed
the
fix-700-deferred-defaults
branch
from
November 25, 2026 12:08
0122865 to
5878126
Compare
Contributor
Author
|
Closing this PR: #779 is already merged on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #700: allows reading and generating JSON Schema for structs that mix
rfl::DefaultVal/rfl::DefaultIfMissingwithrfl::Validatorfields whose default value is invalid, while keepingrfl::Validatortrivially copyable.Example
How it works
T{}throws duringread_struct_with_default, the parser retriesT{}inside a thread-local deferral scope (rfl::internal::DeferredDefaults, exported viaRFL_APIinsrc/rfl/internal/DeferredDefaults.cpp) whereValidator()keeps its invalid default and increments a counter instead of throwing.Tto confirm it holds at least as many invalidValidators as were deferred; after reading, it walks every missing field's default and fails if any invalidValidatoror uncheckable opaque type remains.Validatorkeeps defaulted copy/move constructors (stays trivially copyable; zero copy-path overhead).Known limits
Validator(e.g.int b = a.value() * 2;) observes its invalid value.Validator(e.g.int port = Positive().value();) fails the read unless another invalidValidatorcopy offsets the count.Validatorinside an opaque class the walker cannot inspect fails the read (as onmain), and a missing field of such an opaque type also fails when deferral is active.try/catchfallback inside a member initializer receives no exception while deferral is active, so that field must be supplied in the input.AI-authored.