Skip to content

Verify autoformatter recursion limit fix (already resolved upstream)#103

Closed
Copilot wants to merge 1 commit intomasterfrom
copilot/fix-autoformatter-recursion-limit
Closed

Verify autoformatter recursion limit fix (already resolved upstream)#103
Copilot wants to merge 1 commit intomasterfrom
copilot/fix-autoformatter-recursion-limit

Conversation

Copy link

Copilot AI commented Dec 6, 2025

The autoformatter was hitting Python's recursion limit on structs/enums with many fields/entries. The compiler front end was previously fixed, but the formatter was not.

Status: Already Fixed

This issue was resolved upstream in google/emboss PR google#215 (Dec 2024). The fix is already present in this fork.

Implementation

  • compiler/util/parser_util.py - New iterative transform_parse_tree() using explicit stack instead of recursion
  • compiler/front_end/format_emb.py - Updated to use parser_util.transform_parse_tree
  • compiler/front_end/module_ir.py - Updated to use parser_util.transform_parse_tree

The iterative approach eliminates the recursion limit entirely (up to available memory):

# Stack-based traversal instead of recursive calls
stack = [(parse_tree, None, False, None)]
while True:
    node, parent, children_completed, transformed_children = stack.pop()
    # ... process node iteratively

Verification

Tests pass with 32k+ entity files (2x the Python default recursion limit):

  • FormatEmbTest.test_very_long_emb
  • ModuleIrTest.test_long_input

No code changes needed—closing as resolved.

Original prompt

This section details on the original issue you should resolve

<issue_title>Autoformatter Hits Python Recursion Limit on structs/enums with many fields/entries</issue_title>
<issue_description>This issue was copied from the upstream repository google/emboss.

Original issue: google#34
Original state: open, created at: 2022-02-15T23:18:39Z, updated at: 2024-07-22T14:24:03Z, by @reventlov


Original description

The compiler front end was previously fixed to avoid deep recursion, but the autoformatter was not.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix autoformatter recursion limit for struct and enum fields Verify autoformatter recursion limit fix (already resolved upstream) Dec 6, 2025
Copilot AI requested a review from AaronWebster December 6, 2025 01:22
@AaronWebster AaronWebster deleted the copilot/fix-autoformatter-recursion-limit branch January 29, 2026 23:28
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.

Autoformatter Hits Python Recursion Limit on structs/enums with many fields/entries

2 participants