Skip to content

Quoted type that is not a named generic can be used as a generic #10445

@asterite

Description

@asterite

Aim

This code compiles but it probably should give some kind of error:

#[foo]
comptime fn foo(_: FunctionDefinition) -> Quoted {
    let t = quote { [i32; 3] }.as_type();
    quote {
        struct Foo<$t> { // This should probably give an error
            x: $t,
        }
    }
}

fn main() {
    let _ = Foo::<i32> { x: [1, 2, 3] };
}

I think the user case of interpolating a quoted type in a generic definition was to interpolate named generics from other types, but other kinds of types should give an error.

Expected Behavior

The compiler should give an error of some sort.

Bug

The compiler accepts the code.

To Reproduce

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Nargo Version

No response

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions