Skip to content

fix: generate help for recursive custom types - #1593

Merged
elizabethengelman merged 20 commits into
mainfrom
fix/recursive_custom_types
Nov 24, 2025
Merged

fix: generate help for recursive custom types#1593
elizabethengelman merged 20 commits into
mainfrom
fix/recursive_custom_types

Conversation

@willemneal

@willemneal willemneal commented Sep 10, 2024

Copy link
Copy Markdown
Contributor

Fixes #1588

Initial minimal failing example. Looking into it, the fix is that we need to change the way the help generates types and their examples. Currently it assumes that types aren't self referential, hence when generating the enum cases it keeps recursing.

So one solution is to create a types table and perhaps use a stack instead. Either way this is a bigger change than I had initially hoped.

@willemneal willemneal linked an issue Sep 10, 2024 that may be closed by this pull request
@willemneal willemneal changed the title fix: fail to generate help for recursive custom types fix: generate help for recursive custom types Sep 10, 2024
@sagpatil
sagpatil requested a review from fnando January 14, 2025 21:19
@elizabethengelman elizabethengelman self-assigned this Nov 13, 2025
@elizabethengelman

Copy link
Copy Markdown
Contributor

Before:

$ stellar contract invoke --source ee --network local --id custom-types -- recursive_enum --help

thread 'main' (2354011) has overflowed its stack
fatal runtime error: stack overflow, aborting

After:

$ stellar contract invoke --source ee --network local --id custom-types -- recursive_enum --help

Usage Notes:
Each arg has a corresponding --<arg_name>-file-path which is a path to a file containing the corresponding JSON argument.
Note: The only types which aren't JSON are Bytes and BytesN, which are raw bytes

Usage: recursive_enum [OPTIONS]

Options:
      --recursive <List(Array<RecursiveEnum | Void>) | Void>
          Example:
            --recursive '{"List":[ {"List":[ {"List":[ RecursiveEnum ]}|"Void" ]}|"Void" ]}|"Void"'

  -h, --help
          Print help (see a summary with '-h')

@elizabethengelman
elizabethengelman marked this pull request as ready for review November 13, 2025 23:26
@elizabethengelman
elizabethengelman force-pushed the fix/recursive_custom_types branch from d226ed1 to 95a110e Compare November 14, 2025 14:43

@mootz12 mootz12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving review as comment as I am not familiar with this code.

LG2M outside of leftover debug log.

cc @fnando

Comment thread cmd/crates/soroban-spec-tools/src/lib.rs Outdated

@fnando fnando left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

Comment thread cmd/crates/soroban-spec-tools/src/lib.rs Outdated
Comment thread cmd/crates/soroban-test/tests/it/help.rs Outdated
@elizabethengelman
elizabethengelman force-pushed the fix/recursive_custom_types branch from d5f4bce to 67110fd Compare November 18, 2025 22:03
@elizabethengelman
elizabethengelman force-pushed the fix/recursive_custom_types branch from 67110fd to e619aa9 Compare November 18, 2025 22:04
@elizabethengelman

Copy link
Copy Markdown
Contributor

@fnando @mootz12 I addressed the feed back y'all gave me, thanks! This should be good to go

@elizabethengelman
elizabethengelman merged commit 96ad868 into main Nov 24, 2025
32 checks passed
@elizabethengelman
elizabethengelman deleted the fix/recursive_custom_types branch November 24, 2025 20:18
@github-project-automation github-project-automation Bot moved this from Backlog (Not Ready) to Done in DevX Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Stack overflow error when interacting with testnet contract

4 participants