Skip to content

Allow unquoting TraitConstraint in trait positions #7389

@asterite

Description

@asterite

Problem

The following code doesn't compile:

struct Struct {}

trait Trait {}

fn main() {}

#[foo]
comptime fn foo(_: FunctionDefinition) -> Quoted {
    let tr = quote { Trait }.as_trait_constraint();
    let st = quote { Struct }.as_type();
    quote {
        impl $tr for $st {

        }
    }
}

It gives this error:

error: Cannot inline values of type `TraitConstraint` into this position
   ┌─ src/main.nr:11:5
   │
11 │ ╭     quote {
12 │ │         impl $tr for $st {
13 │ │
14 │ │         }
15 │ │     }
   │ ╰─────' Cannot inline value `Trait`

Happy Case

The above code should compile.

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions