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

Formatter adds extra < when formatting a function #5300

Closed
vezenovm opened this issue Jun 20, 2024 · 0 comments · Fixed by #5303
Closed

Formatter adds extra < when formatting a function #5300

vezenovm opened this issue Jun 20, 2024 · 0 comments · Fixed by #5303
Labels
bug Something isn't working formatter good first issue Good for newcomers

Comments

@vezenovm
Copy link
Contributor

Aim

I want to be able to format the following bad function:

fn blah < T >  (  foo: T) {}

Expected Behavior

I expect the following formatted function from the above:

fn blah<T>(foo: T) {}

Bug

Instead I get this:

fn blah<< T>(foo: T) {}

To Reproduce

  1. Write out the function above in a Noir program
  2. Run nargo fmt

Project Impact

Nice-to-have

Impact Context

Complicates being able to write more complex formatting tests.

Workaround

None

Workaround Description

The workaround is to simply not have any spaces before declaring generics in a function which is not ideal.

Additional Context

No response

Installation Method

Compiled from source

Nargo Version

noirc version = 0.31.0+4a1f8992f5296bc38505fba8e98d9fd3a4264c97

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@vezenovm vezenovm added bug Something isn't working good first issue Good for newcomers formatter labels Jun 20, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jun 20, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jun 20, 2024
vezenovm added a commit that referenced this issue Jun 20, 2024
…ion (#5303)

# Description

## Problem\*

Resolves #5300 

## Summary\*

Previously the formatter was inserting an extra `<` when formatting
functions with a space before `<` when specifying generics. We currently
mark the starting span for a list of generics as the end of the function
name. Having this be the starting span would cause the first generic of
the sequence to have `<` marked as a leading string when it should not
have been. We now start the span for a function's generics by looking
for `<` rather than starting the span at the end of the function name.

## Additional Context



## Documentation\*

Check one:
- [X] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [X] I have tested the changes locally.
- [X] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formatter good first issue Good for newcomers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant