Constrain the callback of the sum-case transform and transform_error#297
Merged
Conversation
This was referenced Jul 13, 2026
🤖 Augment PR SummarySummary: Tightens the immediate-context constraints for sum-delegating monadic statics so invalid callbacks are rejected via constraints (dropping non-viable overloads) rather than failing during deduced-return body instantiation. Changes:
Technical Notes: This addresses overload-resolution poisoning and hard errors from failures discovered only inside deduced-return bodies, aligning behavior with other monadic helpers and pfn compatibility. 🤖 Was this summary useful? React with 👍 or 👎 |
ad37ed3 to
a8019a3
Compare
The sum-delegating statics constrained only the grade, leaving callback validity to be discovered inside the deduced-return body. Two consequences, both outside the immediate context: a callback no alternative could take was a hard error where the non-sum path cleanly drops the candidate, and overload resolution was poisoned - the losing `const &` candidate formed its signature too, so a visitor serving only the category the call selects made the call ill-formed. Constraining the callback in the immediate context, as `sum::transform` itself does, means a partial visitor is now enough. The existing tests spell all four value categories in every visitor because they had to; the new blocks assert they no longer do. Closes #277 Assisted-by: Claude:claude-opus-4-8[1m]
The body puts the untouched value into the result, but only the noexcept spec weighed that copy - the requires-clause did not, alone among the monadic statics (`_or_else`, `_and_then` and `_transform` all carry their untouched-side conjunct). The copy was therefore checked while instantiating the deduced-return body, and since `const &` binds rvalues, the losing candidate hard-errored for a move-only value type: `fn::expected<move_only, E>` could not call `transform_error` from any value category, where `pfn::expected` supports the rvalue call and cleanly drops the lvalue one. A pfn -> fn switch turned valid code ill-formed. Closes #278 Assisted-by: Claude:claude-opus-4-8[1m]
3acb5e5 to
23c55fa
Compare
Member
Author
|
augment review |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Bronek
added a commit
that referenced
this pull request
Jul 13, 2026
Take #297's new constraint sections for the sum-case transform and transform_error, and retire the GAP notes they answer. Both defects were hard errors, so the suite could only describe them in comments: a callback no alternative accepts now drops the candidate, a visitor need only serve the category the call selects, and a move-only value drops the copying overloads. Main's blocks land as SECTIONs, keeping the suite free of the BDD macros. Assisted-by: Claude:claude-opus-4-8[1m]
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.



Two missing conjuncts in the constraints of the monadic statics, both leaving a failure to be discovered inside the deduced-return body instead of the immediate context.
Constrain the callback of the sum-case
transformandtransform_errorThe sum-delegating statics constrained only the grade, leaving callback validity to be discovered inside the deduced-return body. Two consequences, both outside the immediate context: a callback no alternative could take was a hard error where the non-sum path cleanly drops the candidate, and overload resolution was poisoned - the losing
const &candidate formed its signature too, so a visitor serving only the category the call selects made the call ill-formed.Constraining the callback in the immediate context, as
sum::transformitself does, means a partial visitor is now enough. The existing tests spell all four value categories in every visitor because they had to; the new blocks assert they no longer do.Require of
transform_errorthat the untouched value can be relocatedThe body puts the untouched value into the result, but only the noexcept spec weighed that copy - the requires-clause did not, alone among the monadic statics (
_or_else,_and_thenand_transformall carry their untouched-side conjunct). The copy was therefore checked while instantiating the deduced-return body, and sinceconst &binds rvalues, the losing candidate hard-errored for a move-only value type:fn::expected<move_only, E>could not calltransform_errorfrom any value category, wherepfn::expectedsupports the rvalue call and cleanly drops the lvalue one. A pfn -> fn switch turned valid code ill-formed.Closes #277
Closes #278
Stack: P3 of 13 — the release-0.1 bugfix queue, merging bottom-up into
main. Based on #296 and to be retargeted tomainonce it merges; the diff shows only this PR's commits. Every stack boundary was validated with a gcc build and the full test suite on top ofmain, and the aggregate branch ran the full CI matrix green (#289).