Skip to content

[Feature] ABI: Add proper support for const generic structs #29079

@mitchmindtree

Description

@mitchmindtree

The ABI currently does not properly represent const generic structs. When a const generic struct is used in a transition, it appears in its monomorphized form rather than preserving the generic type with concrete arguments.

Example

struct Foo::[N: u32] { a: [u32; N] }
transition bar(f0: Foo::[42]) -> Foo::[42] { .. }

Desired behavior

  • Type declarations should include const parameters (e.g., Foo with parameter N: u32).
  • Type references in transitions should include concrete arguments (e.g., Foo::[42]).

Changes needed

  • Add const_params: Vec to Struct for type declarations.
  • Add const_args: Vec to StructRef for type references.

Possible Approach

May require a multi-phased ABI generation:

  1. After type-checking: capture generic type declarations with their const parameters.
  2. After ConstPropUnrollAndMorphing: capture concrete const arguments in transition signatures.

Related discussion: #29064

Metadata

Metadata

Assignees

Labels

featureA new feature.🖥️ CLIAnything related to the Leo CLI.🧬 JSON ABIEverything related to the JSON ABI

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions