Repository navigation
Read structs with defaults that hold a Validator without a valid default - #780
Draft
clockblocker wants to merge 1 commit into
Draft
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
Contributor
Author
|
Converting this to a draft so that #786 can be reviewed first. Both PRs change Once #786 lands, I'll rebase this PR onto it and drop the commit "Generate a schema for structs that cannot be default-constructed", which #786 makes redundant. #786 doesn't fix #700, so the rest of this PR stays as it is. |
clockblocker
force-pushed
the
fix-700-deferred-defaults
branch
from
November 16, 2026 05:18
bf178ee to
9fa1d1d
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]>
clockblocker
force-pushed
the
fix-700-deferred-defaults
branch
from
November 21, 2026 09:45
9fa1d1d to
2d33403
Compare
This branch has not been deployed
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.