Repository navigation
flowc: issues batch 4 (statics, imports, &call(), range loops, *p, strict checks) - #1082
Merged
Merged
Conversation
This was referenced Sep 30, 2026
godofecht
force-pushed
the
fix/flowc-issues-batch-4
branch
from
September 30, 2026 12:53
8a8394e to
db534da
Compare
A prefix dereference at the start of a line, touching its operand, ends the expression on the line before it. `let p: ptr<i32> = &x` followed by `*p = 7` used to parse as `&x * p = 7`.
String imports that step back (m/../x/c.flow) are normalized before the already-bundled check, so the module is emitted once. Paths without a . or .. segment are unchanged.
sem_check looked the call up as a generic instance named sizeof_T and reported it undefined. With no user function named sizeof, it is the builtin cgen emits as ((int64_t)sizeof(T)).
…d indexed concat operands - A field read or store through a module-level ptr<T> uses -> (#1078): expr_type_node now resolves a module static's annotation. - A struct literal copying a sized array field of a struct from another bundle module copies it with memcpy (#1074). Each module records its structs' array fields in the signature table as [Struct.field. - &f() spills the call result to a one-element compound literal and takes the element's address (#1066). - A numeric or bool element of a pointer or array as a string + operand is formatted by its element type (#1009, third case).
for i in a to b chose its step per iteration with (a <= b) ? 1 : -1, so LLVM saw a non-constant stride and did not vectorize. The direction is now taken once: with literal bounds only the loop that runs is emitted, otherwise an ascending and a descending loop sit under one test of the bounds. scale_for from the issue goes from scalar fmadd to fmla.4s at -O3.
…1046) The formatter read `*p = 7` at the start of a line as a continued product and wrote ` * p = 7`, which the parser now reads differently.
…check parity ceiling (#952)
A Flow function named like a POSIX function the preamble's headers declare with another signature is renamed for the unit, as heapsort and index already are. `function wait(t: ptr<Tapper>, frames: i32)` clashed with <sys/wait.h>, which <stdlib.h> includes.
The note under a parse error at `if` straight after `else` now says Flow spells it `elif`, in place of the reserved-word note, which misled here.
godofecht
force-pushed
the
fix/flowc-issues-batch-4
branch
from
September 30, 2026 12:53
db534da to
3a660bc
Compare
godofecht
added a commit
that referenced
this pull request
Sep 30, 2026
…1090) Ports the two fixes in #1081 that #1082 did not cover, with their tests. - #1050: an array literal used as a value (indexed, cast or measured with len) gets a compound literal's type, `(int32_t[]){ ... }`, because a bare initializer list is not a C expression. `let a = [1, 2, 3]` takes its element type and dimensions from the literal, and a statement-level literal evaluates nested rows for their effects. - #1048: a module static of type `&[T]` or `&mut [T]` initialised from `null` is the empty span, as `span<T>` already was. Tests, from #1081: `tests/lang/test_array_literal_value.flow`, `tests/lang/test_static_span_null_forms.flow` and the `tests/cgen/array_literal_value` golden. Both lang tests failed on main before this change. Local gates: bootstrap fixed point, self_host_full, roundtrip, cgen 107/0, test-lang 230, every parity gate (parity_shader_dsl only at its Metal step, as always on this Mac), parity_typecheck, typecheck_rules, conformance, mlir_commands 72/72, fuzz, corpus parity and the ratchet.
Merged
6 of 8 tasks
godofecht
added a commit
that referenced
this pull request
Sep 30, 2026
New stdlib modules: std.process (argv, captured output, exit status, timeout, env and cwd; #961), std.regex with Python re semantics (#962), and std.os for errno and signals, with extern const for C constants and layouts (#1075). The DSL expanders share compiler/src/bytebuf.flow (#985). repo_stats and python_ratchet run git through std.process. Import paths: #1082 and this PR each normalized import paths. There is now one normalization, flowc_resolve_normalize, applied to every import form. A path that still differs is compared with the known ones as an absolute path. #1082's flowc_resolve_normalize_dots is removed. Both tests pass: test_import_dot_paths (#1073) and test_import_normalized_path. API change, on purpose: lib/stdlib/process.flow is rewritten, and the old helpers it exported (run_cmd, have_cmd, env_is, str_eq) are gone. No tracked program or document imported them from std.process, so they get no forwarding exports. The LSP completion transcript is re-recorded without str_eq. The MLIR corpus is re-recorded for the programs that import changed compiler modules, and #908's span_elem_addr golden is kept as merged.
godofecht
added a commit
that referenced
this pull request
Sep 30, 2026
…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.
godofecht
added a commit
that referenced
this pull request
Oct 1, 2026
* cli, process: drop the #1078 and #1089 workarounds Both bugs are fixed on main (#1082, #1102). Read SINK fields straight off the module static, and spell the C strings in the sys.flow and std.process shims as quoted literals instead of char arrays. * packaging: drop flow-driver from the Homebrew formula flow-driver was deleted in #1095. The ./flow stub builds tools/flow_cli from compiler/bootstrap, so tools/ is always installed beside it. * parity_typecheck: read logs as text with grep -a Some frontend logs echo source bytes that are not valid UTF-8. GNU grep then printed "binary file matches" on stderr 151 times per CI run and left the message empty. The verdicts and the class table are unchanged. * cli: keep the toolchain state in string statics #1103 allows module-level strings (#1086), so the Toolchain struct behind a pointer static and its tc() accessor (a #1078 workaround) go. * parity_typecheck: keep the shell line count flat The shell ratchet counts lines; the rationale for grep -a lives in the previous commit message.
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.
Flowc fixes, batch 4. Each issue was reproduced on main first, and each fix comes with a
tests/langortests/cgencase that fails on main.Fixes #1078
Fixes #1074
Fixes #1073
Fixes #1066
Fixes #1009
Fixes #952
Fixes #1004
Fixes #1046
Fixes #1045
Fixes #1080
Fixes #986
Changes
*pdereference is a parse error #1046*p = 7on the line afterlet p: ptr<i32> = &xparsed as&x * p = 7. When a*is the first token on its line and touches its operand, it now starts a new statement. The same rule is in the parser (flowc_parse_binop_kind) and the formatter, sofmtno longer rewrites the line as* p = 7. A continued product keeps its space (* b) and still parses as one. Test:tests/lang/test_prefix_deref.flow(new case).ptr<T>now emits->.CgenBufrecords the module root, andflowc_cgen_expr_type_noderesolves a module static's annotation. Test:tests/lang/test_static_ptr_field.flow.[Struct.fieldentries for its array fields into the bundle signature table. Test:tests/lang/test_import_struct_array_field.flowwithtests/fixtures/modules/testlib/lattice.flow.m/../x/c.flow) are normalized before the already-bundled check, so the module is bundled once. Only paths with an interior.or..segment change. Test:tests/lang/test_import_dot_paths.flowwithtests/fixtures/modules/dotpath/. The fixture module has a top-levelconst, which is the case where bundle typecheck used to fail.&f()now becomes(&((__typeof__(f()))[1]){ f() })[0]): a one-element compound literal that lives to the end of the block. The call still runs once. Test:tests/lang/test_addr_of_call.flow.divscallsdiv_Dual_f32, andload_file(&reader, path)takes the address. The fix covers case 3: in"x" + p[0], a numeric or bool element of a pointer or array (includingarray_f32) is converted by its element type.examples/gpu/gpu_fft.flownow compiles, and its link step still needs the runtime. Test:tests/lang/test_concat_index_number.flow.sem_check) now typessizeof<T>()asi64, which is how cgen emits it, as long as no user function is namedsizeof. Thestdlib/concurrent.flowhalf of the issue already worked on main when the program passes&m. The program in the issue passesmby value, which is flowc strict check accepts a struct value for a ptr<T> parameter #1080. Test:tests/lang/test_sizeof_generic.flow.compiler/fixtures/stage_a_sizeof.flowis now accepted where the retired Python checker rejected it, so the Darwinpy-onlyceiling incompiler/fixtures/typecheck_parity/ceiling.txtgoes from 5 to 6. That file lists it as an intended difference.for i in a to bwith no step used to choose their step on every iteration (__flowc_up ? 1 : -1). The direction is now decided once. With literal bounds, only the loop that runs is emitted. Otherwise an ascending and a descending loop sit under a singleif ((a) <= (b)). Each loop has a constant step. At-O3on arm64,scale_forfrom the issue went from 0 to 10fmla.4sinstructions. Test:tests/cgen/for_range_affinechecks the text and the run in both directions. Thecgen_forself-test was updated to match.wait,waitpid,wait3,wait4,chmod,umaskorgetlineare renamed for the unit, the wayheapsortandindexalready are. Names that flowc already treats as libc externs (stat,mkdir,system, ...) were left out of the list. Test:tests/lang/test_posix_named_functions.flow.ptr<T>parameter of a plain call. A method receiver (m.take()) is still accepted, because cgen takes its address there. Tests:tests/cgen/struct_for_ptr_param(reject) andtests/lang/test_method_receiver_address.flow.else ifparse error should suggestelif#986 A parse error atifdirectly afterelsenow adds the note "Flow spellselse ifaselif", instead of the reserved-word note. Test:tests/cgen/else_if_hint.Bootstrap C is regenerated in its own commit (fixed point at gen2).
Checked on main and already fixed
#1005, #954, #1010, #1036, #1037, #1038 (it compiles, and linking needs the concurrency runtime that
test-langadds), #1039, #1040, #1042, #1043, #1044, #1047, #1048, #1049, #1050, #1051, #1052. #1041 is a merged PR.Emitted C for unaffected programs
Every tracked
.flowfile (3093) was emitted with the main flowc and with this branch, and the outputs were diffed.examples/gpu/gpu_fft.flow, which did not compile before.tests/lang/test_prefix_deref.flow.Gates (macOS arm64)
All run on this branch with the regenerated bootstrap:
bootstrap_from_c.sh --verify,self_host_full.sh,roundtrip.sh: passparse_coverage.sh --check,fmt_check.sh --check: passtests/cgen/run.sh: 105 passed, 0 failed./flow test-lang: 227 of 227 passcorpus_parity.sh --check: passparity_typecheck.sh --check: pass. Thepy-onlyceiling went from 5 to 6 forsizeof<T>(), see flowc strict check: sizeof<T>() is an undefined function (sizeof_i64) #952 above.typecheck_rules.sh: passparity_dap,parity_dynamics_dsl,parity_effects,parity_field_dsl,parity_flow_blocks,parity_lowering,parity_mlir,parity_project_test,parity_proofs,parity_targets: passparity_shader_dsl: passes except the Metal compile step. This Mac has no Metal toolchain.tests/mlir_commands/run.sh: 72 passed, 0 failedThe MLIR corpus digests of
test_parser_python_forms.flowandtest_parser_span_mutability.floware refreshed, because both importcompiler/src/parser.flow.