Skip to content

Variadic ok returns Result unconditionally and present cases generates typed per-option methods (D242) - #3642

Merged
ehartford merged 1 commit into
mainfrom
variadic-ok-result-present-cases
Nov 27, 2026
Merged

ehartford merged 1 commit into
mainfrom
variadic-ok-result-present-cases

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Implements #3128 (D242, delegated under D237/D98 from D235 item 9a; spec v7.98).

  • Parser & AST (src/Ast.with, src/Parser.with): added present cases / present cases stripping <PREFIX> fn clause (FacadeVariadicPresentClause.PresentCases).
  • Sema (src/Sema.with, src/SemaFacade.with): collects and validates present cases (refuses duplicates, refuses use on non-variadic fn items, refuses invalid derived names and collisions with other cases or host operations), registers each per-option method identically in facade_index_pair_ops (generic callback/userdata setters and concrete retained/invoking/keeping ops) and facade_index_retention_releases (until).
  • Facade rendering (src/compiler/FacadeRender.with): under ok CONST, every listed variadic case now unconditionally returns Result[T, E] for fills T and Result[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 resource message. Under present cases [stripping PREFIX], also renders typed per-option methods (or free functions) omitting the selector parameter and substituting the selector constant directly.
  • MIR pair-flow (src/MirForeignPairs.with): recognizes Result status edges via Sema variant discriminants (Ok/Err, invariant under WITH_DEBUG_PERMUTE_TAGS), handling ?, match, if let, .is_ok(), .is_err(), not, .unwrap(), and .expect(), while continuing to refuse unhandled failures.
  • Spec & decision log: 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.
  • Contracts, UAT & tests: added present cases stripping CURLOPT_ to test/lib/contracts/libcurl.with and uat/libcurl.uat; updated uat/fixtures/libcurl_main.with to use easy.nosignal(1)? / easy.url(...)? / easy.writefunction(on_data)? / easy.writedata(sink)?; updated existing variadic ok tests; added behav_3128_variadic_ok_result_and_present_cases.with, err_3128_present_cases_collision.with, err_3128_present_cases_non_variadic.with, and err_3128_present_cases_unhandled_failure.with.

closes #3128

@ehartford
ehartford force-pushed the variadic-ok-result-present-cases branch from db900cf to 2e00577 Compare November 27, 2026 00:31
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery and :release-checks GREEN on 2e00577c7 (WITH_CODEGEN_EMIT_WIDTH=2):

  • with run tools/verdict.with out/battery/battery.log -> rc=0 green (battery: GREEN (2e00577c7), wall=1024s, all 12/12 macOS UATs including libcurl)
  • WITH=$PWD/src/main src/main build :release-checks -> survey: all targets green, [fixpoint] stage2 == stage3 over all 16 units of the compiler, EMIT-C OK, EMIT-C FIXPOINT, all 6 rt-bundle-*-fixpoint, issue61-regression + all 5 invariance-*, all 6 *-wo-drift (wall=1482.8s).

@ehartford
ehartford marked this pull request as ready for review November 27, 2026 03:12
@ehartford
ehartford merged commit 4c3d77a into main Nov 27, 2026
1 check passed
@ehartford
ehartford deleted the variadic-ok-result-present-cases branch November 27, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant