Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integers in attribute arguments are always passed as Fields #6373

Closed
jfecher opened this issue Oct 28, 2024 · 2 comments · Fixed by #6640
Closed

Integers in attribute arguments are always passed as Fields #6373

jfecher opened this issue Oct 28, 2024 · 2 comments · Fixed by #6640
Assignees
Labels
bug Something isn't working

Comments

@jfecher
Copy link
Contributor

jfecher commented Oct 28, 2024

Aim

#[foo(32)]
comptime fn foo(_f: FunctionDefinition, i: u32) {
    println(std::meta::type_of(i));
}

fn main() {}

Expected Behavior

u32 to be printed

Bug

Field is printed, and if we use i in an operation with a u32, e.g. i == x we'll get an error that we can't perform an equality on a Field and a u32.

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

@jfecher jfecher added the bug Something isn't working label Oct 28, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Oct 28, 2024
@asterite
Copy link
Collaborator

I'm not sure what's the best way to solve this.

Right now we check that the types unify, but the value we pass doesn't change. So if we pass a Value::Field it remains a Field.

We could cast that value to the target type, though that would only work for primitive types. That said, you can't pass an array in an attribute because right now it doesn't parse... but I guess we'd eventually want to support that.

@jfecher
Copy link
Contributor Author

jfecher commented Oct 29, 2024

@asterite I'm not sure on a good way either. I suppose we'd have to pass down an expected type when creating the attribute arguments to begin with.

@asterite asterite self-assigned this Nov 27, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants