Skip to content

Fix string-concat truncation that broke the Flow repo-stats JSON - #207

Merged
godofecht merged 1 commit into
mainfrom
fix/repo-stats-string-concat
Aug 5, 2026
Merged

godofecht merged 1 commit into
mainfrom
fix/repo-stats-string-concat

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Summary

The first Repository Stats run on main compiled and executed the Flow counter, then reported that its JSON disagreed with the Python reference. Only the JSON was stale — the README matched.

Root cause: _is_string_expr did not treat function calls as strings. A helper like area_pair_json(...) used in out + area_pair_json(...) was therefore forced through _gen_stringify_expr, which copies into a 64-byte snprintf buffer. Anything longer was silently truncated:

-      "lines": 3591,
+      "lines": 35913

Closing braces were chopped the same way, which is why the JSON structure itself was corrupted.

Fixes

  • Teach _is_string_expr to use type inference so string-returning calls go straight into flow_strcat
  • Let the stats workflow commit Python output when Flow still disagrees, so a generator bug can never again leave the README stuck on stale hand-written numbers
  • Capture Flow's disagreed JSON as an artifact and fail the job after the commit when parity is still broken
  • Regression tests for the snprintf-wrapping pattern

Test plan

  • Flow vs Python JSON now byte-identical after the fix (diff empty)
  • Generated C for out + long_piece() contains flow_strcat(..., long_piece()) with no snprintf("%s", long_piece())
  • tests/unit/test_string_concat_calls.py (2) + existing stats/cast tests (26) pass
  • CI green; stats workflow on merge should report Flow parity OK

Made with Cursor

`_is_string_expr` ignored function calls, so a `string`-returning helper
used in `a + f()` was forced through `_gen_stringify_expr` and copied
into a 64-byte snprintf buffer. The repo-stats JSON emitter lost digits
and braces that way (`"lines": 35913` became `"lines": 3591`), which is
exactly what the first stats run on main reported.

Recognize inferred string types so the call goes straight into
flow_strcat. Also let the stats workflow commit Python output when Flow
still disagrees, and surface Flow parity as its own non-blocking-then-
failing check so a generator bug can never again leave the README stuck.

Co-authored-by: Cursor <[email protected]>
@godofecht
godofecht merged commit 1aafc28 into main Aug 5, 2026
12 checks passed
@godofecht
godofecht deleted the fix/repo-stats-string-concat branch August 5, 2026 19:16
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.

1 participant