Skip to content

Allow module statics of struct types - #1616

Merged
godofecht merged 31 commits into
mainfrom
issue-562-module-statics-8220065690770900155
Nov 11, 2026
Merged

godofecht merged 31 commits into
mainfrom
issue-562-module-statics-8220065690770900155

Conversation

@godofecht

@godofecht godofecht commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #562. Supersedes the overlapping, closed #1620 implementation.

This change enables module statics containing strings and struct values, including nested constant aggregates and fixed arrays of strings/structs, without losing their initialized values.

  • Semantic checker: recursively validates compile-time-constant struct and array literals, rejects record-update initializers and repeat-array forms that are not supported for statics, and preserves the existing persistent-domain TransportSafe restriction.
  • C backend: emits recursive C file-scope designated initializers, preserving nonzero fields and nested arrays. It does not emit the {0} placeholder from the discarded Allow struct and string in static declarations #1620 approach.
  • MLIR backend: admits struct globals and recursively emits LLVM aggregate constants for nested arrays and fields.
  • Bootstrapping: regenerated compiler/bootstrap/flowc_stage_a.c using ./compiler/scripts/bootstrap_from_c.sh --regen (fixed point generation 2) and passed --verify. The temporary regeneration workflow was removed.
  • Regression: tests/lang/module_statics_struct.flow checks strings, struct fields, nested structs, array fields, arrays of structs, and arrays of strings. The negative typecheck fixture and MLIR corpus baseline are retained.

The feature branch was reconciled with current main as a merge commit, preserving unrelated upstream fixes; the diff against current main is limited to the seven relevant files.

The final MLIR corpus digest for tests/lang/test_only_guard.flow was reconciled against the current emitter and the matching independent build-mode guards work; 2,733/2,734 previously matched on the initial full run. The original drifted bootstrap has been regenerated and passed --verify, and the initial self-host roundtrip and language tests passed. GitHub auto-merge is enabled; exact-head CI and merge-queue validation must pass before merging.

@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 14 commits October 23, 2026 19:08
…-8220065690770900155-5930509473570132711

Fix CI: Update stale MLIR digest for static_array_element.flow
… notes

- Updated `compiler/fixtures/mlir/corpus.txt` with correct digest for `static_array_element.flow`.
- Added `.note.GNU-stack` section for Linux to `runtime/flow_fctx_arm64.S` and `runtime/flow_fctx_x86_64.S` to resolve linker executable stack warnings.
- Dropped the corresponding ld warnings from `tests/cli/goldens/linux/record_two_frames.err`.

Co-authored-by: godofecht <[email protected]>
…-8220065690770900155-16457245074030375672

Fix CI failures in PR #1616: updated MLIR corpus digest and GNU stack notes

Copy link
Copy Markdown
Contributor Author

CI repair triage (2026-11-02): the red checks on this stale head are infrastructure failures, not demonstrated compiler-test regressions. The failing jobs ran on Ubuntu 26.04 and ./.github/actions/install-toolchain failed during apt installation with libllvm22 version conflicts and libxml2 (>= 2.7.4) ... not installable (see CI run and target-backend run). Current main has passing CI with updated runner/toolchain configuration. Reconcile this feature branch with current main, retaining its static-declaration semantics and tests; regenerate the checked-in bootstrap and MLIR corpus only from the merged compiler, then require fresh Linux/macOS, self-host, goldens, wasm32 and bpfel checks. Re-running the obsolete Ubuntu 26.04 workflow unchanged would not establish a code fix. Do not drop or bypass tests.

Copy link
Copy Markdown
Contributor Author

Merge coordination: #1616 and #1620 both implement issue #562 (struct/string module statics) and overlap in compiler/src/sem_check.flow, compiler/src/mlirgen.flow, tests/lang/module_statics_struct.flow and generated bootstrap. The old branch also carries unrelated workflow/runtime changes. Please choose one canonical implementation and rebase it onto current main; carry forward C backend initialization from #1620 and preserve tests, then regenerate bootstrap and corpus and verify exact-head CI. Merging both historical branches wholesale risks duplicate changes and regressions. This is a prerequisite before promoting either branch.

Flow PR integration and others added 3 commits November 6, 2026 02:22
…icts

Preserve constant struct/string and array static checks, MLIR global handling and module regression tests while keeping the latest main bootstrap binary. Rebase 37 Stage-A C hunks, accounting for 18 generated local identifiers introduced on main. Superseded competing PR #1620 requires separate consolidation.
godofecht and others added 3 commits November 6, 2026 11:47
* Supersedes #1577 and #1623 (re-applied on current main). Part of MLIR parity.

- Re-applied C build-mode guards fix to compiler source `attributes.flow` and regenerated `flowc_stage_a`.
- Restored `test_only_guard` fixtures and updated the `corpus.txt` hash.
- Removed obsolete documentation notes regarding `test_only_guard` and network timeouts.

Co-authored-by: godofecht <[email protected]>

* Supersedes #1577 and #1623 (re-applied on current main). Part of MLIR parity.

- Re-applied C build-mode guards fix to compiler source `attributes.flow` and regenerated `flowc_stage_a`.
- Restored `test_only_guard` fixtures.
- Updated `corpus.txt` hash for the restored test and 6 existing files due to the fix resolving their divergence.
- Removed obsolete documentation notes regarding `test_only_guard` and network timeouts.

Co-authored-by: godofecht <[email protected]>

* Supersedes #1577 and #1623 (re-applied on current main). Part of MLIR parity.

- Re-applied C build-mode guards fix to compiler source `attributes.flow` and regenerated `flowc_stage_a`.
- Restored `test_only_guard` fixtures and updated `corpus.txt` hash for it.
- Updated `corpus.txt` hashes for 6 tests affected by the compiler source change (`test_attributes`, `test_parser_python_forms`, `test_parser_span_mutability`, `test_recognition_ssa`, `test_semantic_stack`, `test_typecheck_overload_integration`).
- Removed obsolete documentation notes regarding `test_only_guard` and network timeouts.

Co-authored-by: godofecht <[email protected]>

* Supersedes #1577 and #1623 (re-applied on current main). Part of MLIR parity.

- Re-applied C build-mode guards fix to compiler source `attributes.flow` and regenerated `flowc_stage_a`.
- Restored `test_only_guard` fixtures and updated `corpus.txt` hash for it.
- Updated `corpus.txt` hashes for 6 tests affected by the compiler source change (`test_attributes`, `test_parser_python_forms`, `test_parser_span_mutability`, `test_recognition_ssa`, `test_semantic_stack`, `test_typecheck_overload_integration`).
- Removed obsolete documentation notes regarding `test_only_guard` and network timeouts.

Co-authored-by: godofecht <[email protected]>

* test(mlir): report expected and observed corpus SHA-256 on parity failure

* test(mlir): scope six build-mode guard corpus digests

Record normalized MLIR SHA-256 observed by exact-head parity gate after adding C build-mode guard. Preserve full corpus tracking, existing fixtures and parity enforcement.

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: godofecht <[email protected]>
)

GitHub retired macos-14 November 2, 2026; update qualification, release and Nix workflows without removing macOS coverage.
…supersedes #1674) (#1682)

Lowers vector literals using vector.from_elements in the MLIR backend,
adds vector cast helpers, handles vector literal type inference and
binop operand casts.

Supersedes #1674
Supersedes #1562
Part of #1576

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: godofecht <[email protected]>
godofecht and others added 2 commits November 7, 2026 01:39
Re-applies #1568 onto tip b1b3103 after #1682.
Supersedes #1568.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: godofecht <[email protected]>
* docs: establish verified idiomatic Flow modernization guide

* docs: link idiomatic Flow guide from documentation index

* docs: register idiomatic Flow guide in wiki navigation
@godofecht
godofecht enabled auto-merge November 8, 2026 01:47
@godofecht
godofecht added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit f256060 Nov 11, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Module statics cannot hold string or struct types, which is the real limit on stateful handlers

1 participant