Repository navigation
flowc: print checker warnings, port the last strict checks, record update on C (#678, #996) - #1091
Merged
Merged
Conversation
The strict checker (sem_check.flow) computed its warnings and never printed them. flowc now prints non-exhaustive match, address-of-pointer and unknown handle handler warnings as FILE:LINE:COL: warning: ..., with the Python checker's text, in both modes. FLOWC_WARNINGS=0 (flowc_emit.sh --no-warnings) silences them, FLOWC_WERROR=1 (--Werror) makes them errors. Warnings inside lib/stdlib and lib/runtime show only with FLOWC_WARNINGS=all. parity_typecheck.sh --write-warnings records the Python checker's warnings (warnings.txt, rev f102d88) and --check holds flowc to them: 3135 inputs agree, none differ. New strict checks, each with a fixture in compiler/fixtures/typecheck_rules: - Invalid escape sequence: \x (the Python lexer's error, fatal); C escapes flowc's own sources use (\x01, \033) stay accepted. - Unsafe import path: ../x.flow (the Python resolver's error). The tools and vulkan demos that imported with .. now import without it. - for range step must not be zero. - flow stage params outside a flow output (fork_records.py's error).
…hon's words (#996) cgen writes a record update as the Python C host did: ({ Name t = base; t.f = v; t; }), with array fields copied by memcpy. The output matches the MLIR emitter's on compiler/fixtures/mlir/record_update.flow; tests/cgen/record_update covers struct and array fields. Flow-stage parameters x |> Stage { k: v } outside a flow output have no lowering: the Python host rejected them (fork_records.py). The checker and the backends now print that error instead of "unsupported in Stage-A".
…igests test_import_dot_paths reached its fixtures through `..`, which is now an unsafe import path. It keeps its point, one module through two spellings, with an interior `./` instead. The 24 corpus programs that import compiler/src modules get new digests, as #1082 did for parser.flow, and warnings.txt is recorded again over the current inputs.
#1091 takes the Python resolver's rule: a string import may not be absolute, start with ~, or hold a .. component. After #1083, lib/stdlib/bytebuf.flow reaches the compiler's byte buffer as ../../compiler/src/bytebuf.flow, and std.regex depends on it, so the rule now exempts modules under lib/stdlib and lib/runtime. A program's own imports keep the Python rule. test_import_normalized_path still reaches bytebuf three ways: through std.bytebuf (the .. spelling), directly, and as ./compiler/src/./bytebuf.flow in place of the .. spelling it wrote itself. test_import_dot_paths and test_import_normalized_path both pass.
… and record update
godofecht
force-pushed
the
fix/flowc-diagnostics
branch
from
September 30, 2026 17:26
cf8e790 to
9a5c27d
Compare
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.
Intent
Linked issue or roadmap item: closes #678. Closes the last two items of #996. Closes the open list in docs/design/mlir-in-flow.md ("What the deletion left open").
What changed:
Checker warnings are printed ([Self-Hosting Phase 1] Port Full Pattern Matching to flowc #678). sem_check.flow computed warnings and dropped them. flowc now prints each as
FILE:LINE:COL: warning: <message>, in the Python checker's words, in strict and lenient mode:Non-exhaustive match: ...(int, bool and enum forms)Taking the address of a pointer (got ptr<T>); ...Handle handler 'X' is not a known capabilityFLOWC_WARNINGS=0(flowc_emit.sh --no-warnings) silences them.FLOWC_WERROR=1(--Werror) prints them as errors and fails the compile. The Python host had no-Werror;--strictand--lenientbehave as before. Warnings insidelib/stdlibandlib/runtimeare hidden unlessFLOWC_WARNINGS=all, the way a C compiler treats system headers. Without that, 15 audio programs printed a warning fromlib/stdlib/audio/io.flow.The last strict checks, ported:
Invalid escape sequence: \xis the Python lexer's error, fatal in both modes. Intentional difference: flowc passes strings to C as written, and its own sources use C escapes ("\x01","\033"), so escapes C defines are still accepted. Rejected:\xwith no hex digit after it, unknown letters, and a short\u.Unsafe import path: ../x.flowis the Python resolver's error. It covers a..component, an absolute path and a~path.for range step must not be zerois new. The Python checker had no such rule, and the wording follows range_sums.py.@rt_safe, and span and domain rules were already ported in selfhost: port the Python type checker to flowc (sem_check) with a parity gate #1071 and have fixtures.Stage-A: lower the constructs flowc now parses as parse-only nodes #996:
Name { ..base, f: v }as({ Name t = base; t.f = v; t; }), the Python C host's shape, with array fields copied by memcpy. The output matches the MLIR emitter's oncompiler/fixtures/mlir/record_update.flow.outputget fork_records.py's error: "flow stage paramsGain { ... }(line N) are only valid for a flow used as a pipeline stage inside a flowoutput". Before, the message was "unsupported in Stage-A".Overlap check
Overlap / dependency notes: rebased on #1082 and #1026. #1082 added tests/lang/test_import_dot_paths.flow, which reached its fixtures through
... That is now an unsafe import path, so the test spells its second path with an interior./and still covers #1073. #1083 is still open. Its C changes are independent, but whichever PR lands second needs a bootstrap regeneration.Evidence
Baseline before this change: on main,
flowc_emit.sh --strictaccepted"\xZZ",for i in 0..10 step 0,import "../x.flow"and a non-exhaustive match, with no output. Record update failed in cgen with "unsupported in Stage-A".Targeted proof: 10 new files in compiler/fixtures/typecheck_rules:
escape_invalid,for_step_zero,import_traversal,flow_stage_outside_outputwarn_match_int,warn_match_bool,warn_match_enum,warn_address_of_pointer,warn_handle_handler,werror_matchtypecheck_rules.shnow accepts# warn:expectations. tests/cgen/record_update covers struct and array fields and the run.Why that proof would detect the old failure: with the previous bootstrap, typecheck_rules.sh fails on the 9 fixtures added for #678.
flow_stage_outside_outputcame later and was not part of that run. The record_update cgen case fails because the old cgen refuses it.parity_typecheck.sh --write-warnings REVrecords the Python checker's warnings incompiler/fixtures/typecheck_parity/warnings.txt(rev f102d88, 47 warnings).--checkcompares them with flowc's: 3133 inputs agree, 0 differ, and the new classes have ceilings of 0.Repository gate(s) run: all pass except the one noted below.
bootstrap_from_c.sh --verify,self_host_full.sh,roundtrip.shparse_coverage.sh --check,fmt_check.sh --checktests/cgen/run.sh(107/107),./flow test-lang(230/230),tests/conformance/run.shcorpus_parity.sh --check,parity_typecheck.sh --check,typecheck_rules.sh(123/123)parity_lowering,parity_effects,parity_proofs,parity_mlir,parity_field_dsl,parity_dynamics_dsl,parity_flow_blocks,parity_dap,parity_project_test,parity_targetscheck_doc_examples.sh --check-ledgerparity_shader_dslfails only at its Metal step: this machine has no Metal toolchain.Generated/bootstrap state:
Risk
Files changed because of the new checks:
demos/vulkan_*_flow/src/main.flowdroppedimport "../../vulkan_abi/renderer.flow". It duplicated the externs instdlib/vulkan_abi_renderer.flow, and breakout now imports that file instead. The Python host already refused these files.scripts/tools/lattice_allpassandscripts/tools/discord_welcomeimport their sibling files by name instead of../<dir>/x.flow. Both still compile.tests/lang/test_import_dot_paths.flowandtests/fixtures/modules/dotpathare covered above.Warnings now appear in
flow compileoutput. On the tracked corpus, outside lib/, they come from about 20 inputs, most of them match fixtures.No unresolved language/API design decision is being implemented implicitly. Two choices are called out above: the stdlib warning filter and the C-escape allowance.
No unrelated generated artifacts or local state are included.
Docs changed when user-visible behaviour or syntax changed:
docs/design/mlir-in-flow.mdanddocs/book/09-expressions-and-matching.md.docs/project/Questions.mdupdated if this needs a language-design decision.Compatibility
docs/project/CHANGELOG.md.The changes: new warnings on stdout;
.., absolute and~string imports refused;step 0refused in strict mode; invalid escapes refused.Agent handoff
Any remaining blocker is recorded in GitHub rather than only in local/session state: none.