Repository navigation
Variadic ok returns Result unconditionally and present cases generates typed per-option methods (D242) - #3642
Merged
Merged
Conversation
…s typed per-option methods (D242, closes #3128)
ehartford
force-pushed
the
variadic-ok-result-present-cases
branch
from
November 27, 2026 00:31
db900cf to
2e00577
Compare
Contributor
Author
|
Battery and
|
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.
Implements #3128 (D242, delegated under D237/D98 from D235 item 9a; spec v7.98).
src/Ast.with,src/Parser.with): addedpresent cases/present cases stripping <PREFIX>fnclause (FacadeVariadicPresentClause.PresentCases).src/Sema.with,src/SemaFacade.with): collects and validatespresent cases(refuses duplicates, refuses use on non-variadicfnitems, refuses invalid derived names and collisions with other cases or host operations), registers each per-option method identically infacade_index_pair_ops(generic callback/userdata setters and concrete retained/invoking/keeping ops) andfacade_index_retention_releases(until).src/compiler/FacadeRender.with): underok CONST, every listed variadic case now unconditionally returnsResult[T, E]forfills TandResult[Unit, E]for all other cases (scalar,str, callback, implied userdata, retained pointer, sized retained pointer), supporting both per-operation and shared error types and resourcemessage. Underpresent cases [stripping PREFIX], also renders typed per-option methods (or free functions) omitting the selector parameter and substituting the selector constant directly.src/MirForeignPairs.with): recognizesResultstatus edges via Sema variant discriminants (Ok/Err, invariant underWITH_DEBUG_PERMUTE_TAGS), handling?,match,if let,.is_ok(),.is_err(),not,.unwrap(), and.expect(), while continuing to refuse unhandled failures.docs/spec/016_ffi.md§16.2b.5,docs/spec/031_contract-language.md§31.5 & §31.8.3,docs/spec/README.md(v7.98),docs/meetings/2026-11-26-D242-variadic-ok-result-and-present-cases.md,docs/meetings/README.md.present cases stripping CURLOPT_totest/lib/contracts/libcurl.withanduat/libcurl.uat; updateduat/fixtures/libcurl_main.withto useeasy.nosignal(1)?/easy.url(...)?/easy.writefunction(on_data)?/easy.writedata(sink)?; updated existing variadicoktests; addedbehav_3128_variadic_ok_result_and_present_cases.with,err_3128_present_cases_collision.with,err_3128_present_cases_non_variadic.with, anderr_3128_present_cases_unhandled_failure.with.closes #3128