noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
821 stars 177 forks source link

Convert a `Type` object into a token stream #5309

Closed jfecher closed 1 week ago

jfecher commented 1 week ago

Aim

We'll need some way to convert a Type into a Quoted object to be able to splice it into another quoted token stream.

Expected Behavior

This conversion should ideally be automatic so that:

comptime fn foo(typ: Type, code: Quoted) -> Quoted {
    quote {
        let _: $typ = $code;
    }
}

Works without needing to call let typ = typ.into_quoted() or similar.

Bug

Currently the conversion used just calls typ.to_string() then lexes the string, but this doesn't work for type variables and seems to tightly coupled.

To Reproduce

1. 2. 3. 4.

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Installation Method

None

Nargo Version

No response

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response