Skip to content

StackOverflowError when printing self-referential struct #33392

Closed
@HFriberg

Description

@HFriberg

I expected the following code

mutable struct node_t
    prev::node_t
    next::node_t
end

x = Vector{node_t}(undef,3);
show(x)  # StackOverflowError

to produce the output

node_t[#undef, #undef, #undef]

but instead it recursed forever until the stack was full.

Bonus info: Adding an unused(?) inner constructor:

mutable struct node_t
    prev::node_t
    next::node_t
    node_t() = new()    # not used anywhere??
end

x = Vector{node_t}(undef,3);
show(x)

makes it behave as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions