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

Suggest removal of the ! if user is attempting to call a function as a macro #6380

Closed
TomAFrench opened this issue Oct 28, 2024 · 0 comments · Fixed by #6384
Closed

Suggest removal of the ! if user is attempting to call a function as a macro #6380

TomAFrench opened this issue Oct 28, 2024 · 0 comments · Fixed by #6384
Assignees

Comments

@TomAFrench
Copy link
Member

Consider the program below

fn main() {
    println!(foo);
}

Here we're trying to do a "rusty" println with a ! however in Noir a println is a regular function rather than a macro call.

Compiling this program results in the output

$ nargo compile
error: Expected macro call to return a `Quoted` but found a(n) `()`
  ┌─ src/main.nr:2:5
  │
2 │     println!("foo");
  │     --------------- Macro calls must return quoted values, otherwise there is no code to insert
  │

error: This macro call is to a non-comptime function
  ┌─ src/main.nr:2:5
  │
2 │     println!("foo");
  │     --------------- Macro calls must be to comptime functions
  │

Aborting due to 2 previous errors

These error messages could be improved as we've clearly found the std::println function but we could directly tell the user that they want to remove the ! from the function call in order to call it. For bonus points we can have a code suggestion in the lsp to remove the ! from this call.

@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Oct 28, 2024
@TomAFrench TomAFrench changed the title Suggest removal of the ! if user is attempting to call a function Suggest removal of the ! if user is attempting to call a function as a macro Oct 28, 2024
@asterite asterite self-assigned this Oct 28, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants