Repository navigation
selfhost: corpus parity 2: closures, runtime checks, lenient mode, and the rest of #1018's gaps - #1025
Merged
Conversation
…d the rest of #1018's gaps One closure representation for function types, the Python host's runtime checks under FLOWC_CHECKS=1, generic templates across bundle modules, parenthesised unary operands (#1017), impl blocks and flow.toml [paths] imports with a fallback, Tensor operator sugar, quantity literals, FLOWC_LENIENT=1, pointer receivers across modules, array<T>(N), @cImport as a plain include, for ranges without a step, and libc-named Flow functions reaching their definitions. Squashed from selfhost/corpus-parity-2 onto main.
test_closure_abi tests the single closure representation flowc uses for function types. The Python host keeps a separate function-pointer ABI and its C does not compile, so tier-2 and Tier 1 failed. A file marked flow:flowc-only in its first three lines is skipped by the Python-host sweep; the flowc bootstrap suite and test-lang on flowc still run it.
Contributor
Author
|
Merge train: squashed onto main after #1021 (one commit with the branch's content, plus a fix commit). test_closure_abi.flow is marked flow:flowc-only and the Python-host tier-2 sweep skips such files; the Python host keeps its own function-pointer ABI, which is why tier-2 and Tier 1 failed. Locally: fixed point OK, bootstrap_from_c --verify and self_host_full pass, every parity gate passes (shader except its Metal step, which needs a Metal toolchain this Mac lacks), parse coverage 2344 >= 2276, fmt gate OK, corpus parity 1044 >= 1033 on Darwin. |
godofecht
force-pushed
the
selfhost/corpus-parity-2
branch
from
September 29, 2026 12:05
753113d to
7d97141
Compare
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
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.
Builds on #1018 (now merged; this branch was built on its head and has main merged in).
Corpus parity (C backend, flowc vs the Python host)
Floor (Darwin): 955 -> 1033. Every fix below has a tests/lang test.
Fixes
(A) -> Ris the fat closure the Python host uses everywhere (fn_A__R { R (*fn)(void*, A); void* env; }): parameters, returns and annotated locals. Capturing lambdas copy their environment to the heap; non-capturing lambdas and named functions go through env-dropping bridges.cfn(A) -> Rstays a plain pointer. Lambda parameters keep their declared types. Test: test_closure_abi.FLOWC_CHECKS=1, set by the driver forflow compile/run/buildandtest-lang): integer/%by zero, every shift, reads of sized arrays and spans out of bounds, with the Python host's macros and messages;flow: <what>and abort (134). Writes stay plain lvalues, as on Python. Runtime library units stay unchecked, as Python's--libraryunits. Integer overflow is not checked on either host (Python's overflow checks are switched off). Test: test_runtime_checks.Chan<T>from stdlib/concurrent), with nested generic calls instantiated at the enclosing types. Test: test_generic_channels (existing).impl blocks:
impl Trait for Typemethods becomeType_Trait_method. Test: test_trait_impl.flow.toml [paths]. Test: toml_paths/test_toml_paths.
Tensor operator sugar. Test: test_tensor_sugar.
Also: quantity literals (
1000.0 Hertz), method calls passing&recvto a pointer receiver in another module,array<T>(N), a step-lessforrange counting toward its end, @cImport emitting only#include(and its functions type-checking), libc-named Flow functions (log(Dual),malloc(i32) -> i32) reaching their definitions, and the python_embed runtime trying every library candidate. Each has a test.FLOWC_LENIENT=1is Python's--lenient: type errors are warnings except the ones Python keeps fatal (capability used as a value) plus constructs Stage-A cannot lower. The driver sets it forflow compile/run/build, where Python passes--lenient;test-langand every direct flowc call (the parity scripts) stay strict, as Python's default--strict. So the units/effects negative fixtures run under compile and are rejected under strict, on both hosts. No file both hosts reject started to build.#1017 (unary operands)
Not reproducible on this tree, main, or selfhost/mlir-emit with any bootstrap: the C backend already wrapped binary operands (#999). Every unary emit site now parenthesizes non-primary operands anyway (C, JS, Metal, WGSL); the JS backend dropped
~entirely. Test: test_unary_parens (!,not,-,~over every binary operator and nested unary/cast operands).Emitted code before/after for every tracked .flow file:
flow compileemits it): 3 files differ, only by added parentheses; none changes meaning: lib/stdlib/psychstats.flow, tests/stdlib/test_psychstats.flow ((-(double)(i))->(-((double)(i)))), tests/lang/test_unary_parens.flow.~was dropped: benchmarks/micro/frame_arena_benchmark.flow, compiler/fixtures/mlir/arith.flow, examples/audio/lifetime_domains.flow, examples/crypto/sha256.flow, lib/runtime/crypto.flow, lib/stdlib/memory_simple.flow, lib/stdlib/memory.flow, tests/core/test_bitwise.flow, tests/lang/test_lifetime_domains.flow, tests/lang/test_unary_parens.flow.What still differs
16 files, none a flowc bug that Python gets right:
\xescape), tools/lsp/main.flow (Python cannot parsehandleas a name). These are Flow tools that must build on flowc, so flowc keeps accepting them.creal(...)with%d(garbage integers); flowc prints the double.Verification
Bootstrap C regenerated last from the Python host build (separate commit); fixed point holds. Passing: bootstrap_from_c.sh --verify, self_host_full.sh, roundtrip.sh, parse_coverage.sh --check, parity_dynamics_dsl, parity_effects, parity_field_dsl, parity_flow_blocks, parity_lowering, parity_mlir, parity_proofs, corpus_parity.sh --check. parity_shader_dsl passes its fixtures and host stub checks; its Metal end-to-end step needs the Metal toolchain, which this machine lacks (as on #1018).
History: the fixes were rebuilt on #1018's rebased head, then origin/main (with #1018 squash-merged) was merged in and the bootstrap C checked against the merged sources (unchanged; fixed point holds).