Skip to content

fix: -O2 default, pointer address type check, regression tests - #428

Merged
godofecht merged 3 commits into
mainfrom
work
Aug 11, 2026
Merged

godofecht merged 3 commits into
mainfrom
work

Conversation

@godofecht

@godofecht godofecht commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Changes

  • src/flow/type_checker.py: reject UnaryOperation('&', ptr) with clear error
  • flow: default opt level -O2 via FLOW_OPT_LEVEL, applied to flowc host and Python host
  • lib/stdlib/memory.flow: grow_uninit, grow_zeroed, alloc_uninit helpers
  • tests/unit/test_const_folding.py: 8 tests for MLIR const folding
  • tests/unit/test_inline_exp_nested.py: 4 tests for inline exp in loops
  • tests/unit/test_ptr_address.py: 4 tests for & of pointer rejection
  • tests/unit/test_grow_helpers.py: 6 tests for uninitialized growth
  • tests/unit/test_arena.py: 12 tests for arena/frame allocator API

Test plan

  • All 1307+ unit tests pass
  • Manual verification: FLOW_OPT_LEVEL=0 and default both work
  • Type checker rejects &p in strict mode, warns in lenient mode
  • grow_uninit uses realloc, alloc_uninit uses malloc, grow_zeroed zeros delta

Closes #420, #421, #422, #423, #424, #425.

This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.

Generated with Devin

#420: MLIR const binary folding already works. Added 8 regression tests
covering subtraction, addition, multiplication, shifts, bitwise or,
i64, large values, and zero-init prevention.

#421: Inline exp() in nested while loops already works (fixed by #414
vectorization pragma fix. Added 4 regression tests.

#423: Type checker now rejects taking the address of a pointer
(ptr<T>). The expression &p where p is ptr<T> silently compiled to
T**, causing runtime garbage. Strict mode emits a type error; lenient
mode emits a warning. Added 4 tests.

#422: C backend defaulted to -O0, overriding FLOW_CFLAGS. Now defaults
to -O2, overridable via FLOW_OPT_LEVEL=0|1|2|3|s. Debug builds still
use -O0. The flowc host link path also honors FLOW_OPT_LEVEL.

All 1307 unit tests pass.

This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
EOF
)
@cursor

cursor Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

…425)

#424: Add grow_uninit, grow_zeroed, and alloc_uninit to
lib/stdlib/memory.flow. grow_uninit is a plain realloc wrapper for
callers who initialize every new element. grow_zeroed zeros only the
new region. alloc_uninit allocates exact size without a minimum
capacity floor.

#425: Arena and FrameArena already exist in the stdlib with
arena_alloc, arena_reset, arena_destroy, frame_begin, frame_alloc,
and frame_end. Added 12 regression tests verifying the API surface
and pointer-bump semantics.

All 18 new tests pass.

This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taking the address of a pointer (ptr<T>) is valid when the callee
expects a pointer-to-pointer (e.g. output parameters like
flow_audio_open(&config, &dev_ptr)). The type checker now warns
instead of erroring, so strict mode no longer breaks audio examples.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

Bug: MLIR generator zero-initializes consts with BinaryOperation initializers (e.g. 0 - 1)

1 participant