Skip to content

spec shaking v2: Support recursive types #1834

@mootz12

Description

@mootz12

What version are you using?

main

What did you do?

With experimental_spec_shaking_v2 that recursively references itself through any built-in container (Vec, Option, Map, Result, a tuple, or a reference), and use it as a contract function parameter or return type:

#![no_std]
use soroban_sdk::{contract, contractimpl, contracttype, Symbol, Vec};

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Recursive {
    pub a: Symbol,
    pub b: Vec<Recursive>,
}

#[contract]
pub struct Contract;

#[contractimpl]
impl Contract {
    pub fn recursive(a: Recursive) -> Vec<Recursive> {
        a.b
    }
}

What did you expect to see?

Invoking recursive to function as expected

What did you see instead?

Stack overflow

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions