Skip to content

#[contractimpl] macro: associated type flattening is one-pass and non-recursive #1779

@mootz12

Description

@mootz12

What version are you using?

Main

What did you do?

Used a chained associated type alias in my Soroban contract:

use soroban_sdk::{contract, contractimpl, Env};

pub trait Chained {
    type Base;
    type Foo;
    type End;
    fn get(env: Env) -> Self::End;
}

#[contract] pub struct Contract;

#[contractimpl]
impl Chained for Contract {
    type Base = u64;
    type Foo  = Self::Base;   // alias chain depth 1
    type End  = Self::Foo;    // alias chain depth 2

    fn end(env: Env, a: Self::End) -> Self::End {   // <-- `a` and return type never resolved to u64
        a
    }

    fn foo(env: Env, a: Self::Foo) -> Self::Foo { // <-- return type never resolved to u64
        a
    }
}

What did you expect to see?

  • A clear compiler error noting I can't use chained associated types like "associated type Self::End could not be resolved; ensure it is not referenced by another associated type or use the concrete type directly"
  • The contract to compile when a single associated type is used as the return value

What did you see instead?

A build error error[E0223]: ambiguous associated type

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