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

Allow fmtstr to be passed to static_assert instead of str. #6884

Open
iAmMichaelConnor opened this issue Dec 19, 2024 · 2 comments
Open

Allow fmtstr to be passed to static_assert instead of str. #6884

iAmMichaelConnor opened this issue Dec 19, 2024 · 2 comments
Assignees

Comments

@iAmMichaelConnor
Copy link
Collaborator

A minor feature request, if it's even possible.

E.g. to print the values of numeric generics that are being compared with static_assert.

@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Dec 19, 2024
@asterite
Copy link
Collaborator

asterite commented Jan 6, 2025

I just looked into this.

For this program:

use std::static_assert;

fn main() {
    let x = 1;
    static_assert(x == 2, "OH NO");
}

we get this error:

error: Argument is false
  ┌─ src/main.nr:5:5
  │
5 │     static_assert(x == 2, "OH NO");
  │     ------------------------------
  │
  = Call stack:
    1. src/main.nr:5:5

Aborting due to 1 previous error

So the message seems to be unused. So first we'd need to display that message, I guess.

But I was wondering, given that we have assert and assert_eq, if it wouldn't make sense to have static_assert_eq instead, and if the two values are different, that would be printed (we'd know the values of the constants so we could easily print those).

@TomAFrench
Copy link
Member

related to the above #7005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants