Skip to content

fix: multiple compiler bugs and project conventions - #419

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

godofecht merged 8 commits into
mainfrom
work

Conversation

@godofecht

@godofecht godofecht commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes 7 issues and adds 1 feature:

Changes

  • src/flow/parser.py: fixed escape validator (backslash was rejected)
  • src/flow/c_generator.py: runtime direction for no-step for loops, conditional vectorization pragmas, _loop_body_is_simple
  • src/flow/mlir_generator.py: _constant_step returns None for no-step loops, cf lowering handles runtime direction
  • flow: capture and display compiler stderr instead of suppressing it
  • src/flow/conventions.py: new module for reading flow.toml conventions
  • src/flow/check.py: new flow check command
  • src/flow/package.py: flow init writes [conventions] and [build] template

Test plan

  • 8 new tests in test_escaped_strings.py
  • 3 new tests in test_transitive_const.py
  • 5 new tests in test_struct_literal_return.py
  • 5 new tests in test_string_concat.py
  • 8 new tests in test_conventions.py
  • All 1299 unit tests pass
  • ruff lint clean

Closes #408, #410, #411, #412, #413, #414, #415.

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

Generated with Devin

Casting u8 to i32 zero-extends correctly via arith.extui, but the result
is a signed i32. Marking it unsigned made downstream >> use arith.shrui
(logical shift) instead of arith.shrsi (arithmetic shift).

Only add to _ssa_unsigned when the target type itself is unsigned.

Fixes #418.

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>
@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.

godofecht and others added 7 commits August 11, 2026 15:42
…zers

Add _fold_const_binary to fold BinaryOperation on integer literals
(e.g. `0 - 1`, `65536 * 2`) into a Literal. Handles +, -, *, /, %, <<,
>>, &, |, ^. Unwraps CastExpression and UnaryOperation(-) to reach the
raw literal.

Applied in generate_const (const declarations) and generate_static
(mutable statics with const-referencing initializers). Also extends
_resolve_const_value to fold BinaryOperation initializers.

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>
…410)

Two fixes:

1. String escape validator (#408): the valid escape backslash was
   rejected because the Python string literal for two backslashes was
   compared against a single backslash character. Fixed to check a
   single backslash. Escaped quotes already worked; the bug was in the
   validator rejecting backslash before the lexer could emit it.

2. Reverse for loops (#410): for i in n-1 to 0 with no explicit step
   now detects the direction at runtime. The C backend emits a ternary
   step and condition. The MLIR backend returns None from _constant_step
   when no step is given, forcing the cf lowering path which handles
   runtime direction via arith.select on the step and comparison
   predicate.

   'to' is exclusive in both directions: 0 to 4 gives 0,1,2,3;
   4 to 0 gives 4,3,2,1.

   Vectorization pragmas are suppressed for no-step loops since the
   direction is not known at compile time.

Tests: 8 new tests in test_escaped_strings.py. All 1278 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>
The flow CLI suppressed all stderr from the Flow compiler with
2>/dev/null, leaving only "FLOW compilation failed" with no detail.
Now captures stderr to a temp file and prints it on failure.

Also adds regression tests for transitive const visibility (#411),
which already works correctly with dot-path imports.

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>
Struct literal returns with embedded function calls already work
correctly. The original failure was likely caused by error suppression
(#413) hiding the real diagnostic. Adds 5 regression tests covering
binary ops, function calls, pointer fields, nested structs, and mixed
initializers.

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>
Vectorization pragmas (pragma clang loop vectorize(enable), pragma GCC
ivdep) were always-on for for loops with explicit steps. This is unsafe
for loops with data-dependent control flow, function calls, or
floating-point accumulation with conditional updates.

Added _loop_body_is_simple() to check whether the loop body contains
only straight-line assignments. Pragmas are now only emitted when the
body has no if/match, no break/continue, no function calls, and no
nested loops.

All 1294 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>
String + string already works correctly via flow_strcat. The original
failure was likely caused by error suppression (#413). Adds 5 regression
tests covering literal concat, variable concat, three-way concat,
concat in print, and concat in function return.

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>
Add flow.toml [conventions] and [build] sections with a flow check
command that warns when source files match avoid patterns.

New modules:
- src/flow/conventions.py: reads flow.toml for avoid patterns, build
  settings, and preferred idioms. Substring or regex pattern matching.
- src/flow/check.py: flow check command. Scans .flow files for
  convention violations.

flow init now writes template [build], [conventions], and [patterns]
sections to flow.toml.

The flow CLI dispatches flow check to the new module.

Tests: 8 new tests in test_conventions.py. All 1299 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>
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: Escaped quotes in string literals cause memory corruption / bus error

1 participant