Repository navigation
Match pfn monadic declarations and constraints to the C++ draft - #459
Merged
Merged
Conversation
Deduce owning optional transform and and_then return types in their bodies, as specified by the standard. Trailing-return substitution could remove the selected overload and bypass a callback's deleted cv/ref overload, allowing a borrow from a temporary through const&. Keep conditional noexcept and valid reference results. Add constexpr and runtime controls for callable categories, lvalue-only callbacks, external references, and temporary reference wrappers; document the hard errors. GCC and Clang full builds and 48/48 tests pass on each. Separate compiler probes reject all 32 previously accepted invalid calls, matching the standard-library controls; mandate errors cannot run in the unit suite. The shared std optional tests compile in C++23 and C++26 on both compilers. Assisted-by: Codex:gpt-6
Keep reference and_then's return deduction in its body so invalid invocations are hard errors. Spell reference transform's result and both or_else result types as specified, preserving their substitution rules, constraints and conditional noexcept. Add paired compile-failure controls for reference and_then and owning monadic cv/ref fallback. Guard extension-only noexcept assertions in the standard-library validation tests. Assisted-by: Codex:gpt-6
Compile each negative callback fixture without its rejected call so an incorrect invocability assertion fails a normal build instead of passing a compile-must-fail test. Assisted-by: Codex:gpt-6
Expose only the unchanged-side constructibility constraints on the four monadic families. Deduce returns in the body so an invalid callback cannot remove the selected overload or become false in a requires-expression. Preserve valid copy fallback and cover rejection with paired compile-fail controls and independently checked callback fixtures. Leave conditional noexcept unchanged. Assisted-by: Codex:gpt-6
Keep error constructibility constraints on and_then and transform while leaving or_else and transform_error unconstrained. Body-deduced returns make invalid callbacks hard errors without removing valid copy fallback. Cover nullary callback rejection, error callback cv/ref fallback, and operations on immovable errors. Leave conditional noexcept unchanged. Assisted-by: Codex:gpt-6
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
|
augment review |
🤖 Augment PR SummarySummary: Aligns
🤖 Was this summary useful? React with 👍 or 👎 |
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.



Helper-based trailing return types made some invalid monadic callbacks disappear through substitution failure. This could select a different cv/ref overload, including one that lets a callback borrow from a temporary owning optional despite deleting its rvalue overload.
For example, this callback explicitly rejects borrowing from an rvalue
Person. Before this change, the rvalueand_thenoverloads disappear through substitution failure, allowing theconst&member overload to invoke the callback with an lvalue instead:This compiles before the fix on GCC and Clang, and AddressSanitizer reports a stack-use-after-scope at
*age. With the fix, both compilers reject theand_thencall. Calling the same callback through a named optional that remains alive is still valid.Match the current C++ draft's public declarations for owning and reference
pfn::optionaland bothpfn::expectedspecializations. Use body-deduced returns where invalid callbacks must produce hard errors, preserve reference optional's explicittransformreturn type, and retain the specified invocability and constructibility constraints. Expected's permitted constructibility-based copy fallback remains available.Add compile-failure tests with successful positive controls and separate fixture checks, plus runtime and constexpr preservation tests. Update TYPE_ALGEBRA, CHANGELOG, and the contributor guidance for rejection tests.
Assisted-by: Codex:gpt-6