Repository navigation
Stage-A batch 2: precedence, scoped name types, sort-modifier names, libc externs, diagnostics - #1003
Merged
Merged
Conversation
godofecht
force-pushed
the
fix/stage-a-batch-2
branch
from
September 29, 2026 06:15
390c1e9 to
2afaad6
Compare
…rds as names flowc put | ^ & << >> on one level below the comparisons. It now uses the Python parser's levels: or, and, |, ^, &, equality, comparison, shifts, additive, multiplicative. cgen emits comparison and logic operators without parens, so a child binop is now wrapped whenever C would regroup it. Emitting every tracked .flow file before and after the change gives identical C apart from compiler/src itself, so no program changes meaning. The parser now marks the modifier identifiers it collects after `|> sort`, and cgen and the typechecker substitute only marked nodes. A variable called desc, descending, unique and so on is an ordinary name. Fixes #995 Fixes #994 Fixes #968
cgen decided whether `+` is string concatenation, and which printf format print uses, by scanning every parameter and let in the module for the name. A same-named declaration in another function could turn string concatenation into pointer addition or print a string with %d. cgen now resolves an identifier to the latest let that precedes it in the function being emitted, then that function's parameters, then a module const. The old module-wide scan stays only as the fallback for code outside a function body. The same lookup resolves struct field types, so println of an f64 field uses %f, a string field concatenates, and field access through a local ptr<Struct> emits ->. A string const is emitted as `const char* const` instead of `const const char*`. Fixes #957 Fixes #993 Fixes #967 Fixes #992 Fixes #984 Fixes #990
A parse failure printed only a byte offset, and in bundle mode not even that. Every parse failure site now also prints path:line:col and the token, and a note when the token is a reserved word. Fixes #970
The preamble now includes <time.h>, so an extern time() or clock() has a declaration. The libc allowlist covers the rest of the stdlib.h, string.h, math.h and time.h functions a Flow extern is likely to name, so their prototypes no longer clash with the headers. The clang pragmas that silence int-conversion and incompatible-pointer-types get GCC twins, and gcc-15 now builds the Stage-A bootstrap C. Fixes #969 Fixes #958
The Python host puts every declaration of an imported module into the program, so a call to a plain function of an imported module compiles there. flowc seeded only exported functions and consts. It now seeds every top-level function (except an imported main) and every const, and the seed tables are larger to hold them. docs/language/modules.md states the rule and how it meets the #950 private-name renaming; its dashes are replaced to satisfy the copy check. Fixes #988
flow_rt_support.c calls CoreFoundation for its fatal-error popup, and test-lang linked the concurrency sources without the framework. The concurrency link flags now carry it on Darwin, so test_generic_channels and any test importing stdlib/concurrent.flow link. Fixes #953
PR #1002 rewrote the em dashes in the Python proof generators. The Flow ports of math_prose, proof_document and claim_path now emit the same sentences, so both hosts produce the same text.
With uncommitted compiler/src edits, ensure_flowc runs roundtrip.sh on the Python host. Every `./flow run` in the roundtrip checks project dependencies with a flowc-built tool, which calls ensure_flowc again, which starts another roundtrip. The processes multiplied until fork failed. The roundtrip now marks itself in the environment, and nested calls use the checked-in bootstrap C.
The preamble now includes <time.h>, so an extern prototype for clock_gettime, clock_gettime_nsec_np, nanosleep, gmtime_r or localtime_r would clash with it. The bench tools and the publish benchmarks declare some of these.
- tools/python_ratchet: print with println; the puts wrapper worked around #948. - scripts/tools/lib/text.flow: ft_join returns a + b directly; the typed local worked around string + on parameters (#957). - scripts/tools/lib/regex.flow: return not (...) directly (#963). - scripts/tools/build_tool.sh: use cc; the clang preference worked around the clang-only pragmas (#958).
godofecht
force-pushed
the
fix/stage-a-batch-2
branch
from
September 29, 2026 06:32
2afaad6 to
8fa00d6
Compare
This was referenced Sep 29, 2026
#1002 made the repo-stats generator write '-' where it wrote 'n/a' and left test_repo_stats expecting the old text, which turned Python tests red on main.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
Rebased onto main containing #1003, #999, #998 and #989. Carries #1001's parse-only mode, located parse errors (flowc_parser_print_error, which the driver, emit and bundle paths now use), theorem/assume/therefore/claim references, flow blocks, handle, ui layout and pipeline blocks, let without initializer, contextual unit, distinct, effect rows, or-patterns, guards, nested patterns, [T; N], capability types, ?, vector literals, soft names, sort-by keys, entropy policies and module blocks, the parse coverage script and its CI floor, and the Python-grammar parser contract test. The #1001/#1003 reconciliation follows the one in #1012.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
…ders retired (#999) The dynamics DSL expander and flow-block lowering run in flowc (dynamics_dsl.flow, flow_blocks.flow) at every source read through flowc_expand_stages_in_place, with parity gates parity_dynamics_dsl.sh and parity_flow_blocks.sh and committed run goldens. The Python expanders become flowc bridges. CI builds flowc before the fuzz run and gives the self-host roundtrip 30 minutes. Bootstrap C regenerated after rebasing onto #1003: fixed point, bootstrap_from_c --verify and self_host_full pass.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
Rebased onto main containing #1003, #999, #998 and #989. Carries #1001's parse-only mode, located parse errors (flowc_parser_print_error, which the driver, emit and bundle paths now use), theorem/assume/therefore/claim references, flow blocks, handle, ui layout and pipeline blocks, let without initializer, contextual unit, distinct, effect rows, or-patterns, guards, nested patterns, [T; N], capability types, ?, vector literals, soft names, sort-by keys, entropy policies and module blocks, the parse coverage script and its CI floor, and the Python-grammar parser contract test. The #1001/#1003 reconciliation follows the one in #1012.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
Rebased onto main containing #1003, #999, #998 and #989. Carries #1001's parse-only mode, located parse errors (flowc_parser_print_error, which the driver, emit and bundle paths now use), theorem/assume/therefore/claim references, flow blocks, handle, ui layout and pipeline blocks, let without initializer, contextual unit, distinct, effect rows, or-patterns, guards, nested patterns, [T; N], capability types, ?, vector literals, soft names, sort-by keys, entropy policies and module blocks, the parse coverage script and its CI floor, and the Python-grammar parser contract test. The #1001/#1003 reconciliation follows the one in #1012.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
…ors as #1003 does roundtrip.sh builds the frontend module by module, so proof_lower.flow (called from cgen, jsgen and the typecheck) is compiled, given a header and linked into flowc_frontend.o and flowc_jsgen_fmt.o. driver.flow keeps #1003's flowc_parser_report where #1001 and #1003 both changed the same line; the roundtrip's keyword_param check (from
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
…ors as #1003 does roundtrip.sh builds the frontend module by module, so proof_lower.flow (called from cgen, jsgen and the typecheck) is compiled, given a header and linked into flowc_frontend.o and flowc_jsgen_fmt.o. driver.flow keeps #1003's flowc_parser_report where #1001 and #1003 both changed the same line; the roundtrip's keyword_param check (from
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.
Stage-A bug batch 2: fixes found while porting the Python tools to Flow.
Fixes
or,and,|,^,&,== !=, comparisons andin,<< >>,+ -,* / %. cgen emits comparison and logic operators without parens, so a child binop is wrapped whenever C would regroup it. I built a flowc with only the old table swapped back in and emitted all 987 tracked.flowfiles that flowc can emit with both. The C is identical except for the new test, so no tracked program changes meaning.|> sort. cgen and the typechecker substitute only marked nodes, sodesc,descending,uniqueand the rest are ordinary names elsewhere. This also fixestest_ordering_hints_port, which passed0for itsdescendingandascendingarguments.letin the function being emitted, then that function's parameters, then a module const. The old module-wide scan remains only for code outside a function body. Struct field types resolve the same way, soprintln(s.f64_field)uses%f, a string field concatenates, andp.xon a localptr<Struct>emits->.const char* const.return not <expr>does not parse #963return not <expr>andreturn dbg <expr>parse.path:line:col: parse error at 'tok', and a note when the token is a reserved word. This covers single-file, driver, bundle gather and bundle typecheck.<time.h>. The libc allowlist covers the rest of stdlib.h, string.h, math.h and time.h. The clang pragmas for int-conversion and incompatible-pointer-types have GCC twins. gcc-15 builds the bootstrap C and all 14scripts/toolsprograms.main) and every const of a dependency, matching the Python host. The rule, and how it meets the Stage-A: private functions with the same name in two modules collide in C #950 private-name renaming, is in docs/language/modules.md under "What the compilers enforce today".-framework CoreFoundationon Darwin, sotest-langlinks programs that importstdlib/concurrent.flow.test_generic_channelsnow passes.Also in this PR
parity_math_prose_expr.py(42 cases) andparity_proof_parse.py(116 cases) pass against docs: clear prose-hook findings repo-wide and fix stale Python references #1002's Python.compiler/scripts/ensure_flowc.sh: when compiler/src had uncommitted edits,./flow runstarted the Gen0 roundtrip. Each./flow runinside that roundtrip ran ensure_flowc again, so the roundtrips nested without bound until fork failed. Nested calls now use the checked-in bootstrap C.Workarounds removed
say/puts wrapper (Stage-A println formats non-literal strings with %d #948) is gone. It prints withprintln.ft_joinreturnsa + bdirectly (Stage-A: local variable types leak across functions, so string + string can compile to pointer addition #957).not (...)directly (Stage-A:return not <expr>does not parse #963).cc. The clang preference is dropped (Stage-A C output: extern prototypes clash with libc headers outside a fixed allowlist, and warnings are silenced with clang-only pragmas #958).Verification
bootstrap_from_c.sh --verify,self_host_full.shandroundtrip.shall pass. roundtrip.sh also runs the new keyword_param diagnostic check.test_ordering_hints_port. Every remaining failure also fails on main..flowfile emitted by origin/main's flowc and by this branch's, then syntax-checked with cc: 833 → 859 compile, and no file regresses../flow test-lang(Python host) passes all new tests plustest_generic_channels.python_ratchet.shPASS.challenges/flow-specific/check.sh self-testpasses 4 checker cases and 43 regex cases.check_doc_links.shpasses. The Flow repo_stats output matchesupdate_repo_stats.py --check; before this PR it did not compile because of Stage-A: string + on a string const compiles to pointer addition #967.Not done
scripts/tools/challenge_checkstill counts 10 ms polls instead of callingtime(). Switching totime()would change the timeout's resolution, so this is not a trivial edit.end_mark, prepare_releasehelp_body, verify_examplesdate -u) are only on the unmergedport/scripts-rest-to-flowbranch.Fixes #995
Fixes #994
Fixes #968
Fixes #957
Fixes #993
Fixes #967
Fixes #992
Fixes #984
Fixes #990
Fixes #963
Fixes #970
Fixes #969
Fixes #958
Fixes #988
Fixes #953