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

Helpful error message when fn is missing #3768

Closed
rahul-kothari opened this issue Dec 11, 2023 · 1 comment · Fixed by #4154
Closed

Helpful error message when fn is missing #3768

rahul-kothari opened this issue Dec 11, 2023 · 1 comment · Fixed by #4154
Assignees
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@rahul-kothari
Copy link

rahul-kothari commented Dec 11, 2023

Aim

It would be nice to have a specific error message when using this (wrong) syntax:

 #[aztec(private)]
 constructor() {
     (...)
 }

Above has the fn keyword missing and it throws with a generic parsing error (Expected an end of input but found contract)
AztecProtocol/aztec-packages#3630

@rahul-kothari rahul-kothari added the bug Something isn't working label Dec 11, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Dec 11, 2023
rahul-kothari added a commit to AztecProtocol/aztec-packages that referenced this issue Dec 12, 2023
Fix a part of the problem highlighted by #3630 

Also created 
* noir-lang/noir#3768
* [Discussion to see why we prioritise Aztec-nr issues over noir syntax
issues. E.g. if we have storage and a syntax error in a method, instead
of showinf the syntax error, we say "no
compute_note_hash_and_nullifier()
found"](https://aztecprotocol.slack.com/archives/C03P17YHVK8/p1702312023384759)
@kevaundray kevaundray added the good first issue Good for newcomers label Jan 15, 2024
@kevaundray kevaundray added this to the 0.24.0 milestone Jan 15, 2024
@signorecello
Copy link
Contributor

Seems like this happen anytime there is a error. Things like missed ,, : instead of ::... Any parsing error will bring this unhelpful message

github-merge-queue bot pushed a commit that referenced this issue Jan 25, 2024
# Description

Using `force(just(Token::EOF))` to ensure the whole file is parsed
appears to hide the module error.

## Problem\*

Resolves #3768

## Summary\*

Before:

```bash
❯ cargo run build
error: Parser: expected an end of input but found #[aztec(private)]
  ┌─ /Users/michaelklein/Coding/rust/noir/test_programs/compile_failure/no_fn_keyword/src/main.nr:1:1
  │
1 │ #[aztec(private)]
  │ -----------------
  │

Aborting due to 1 previous error
```

After:

```bash
error: Unexpected main, expected one of fn, internal, open, pub, struct, unconstrained, Attribute
  ┌─ /Users/michaelklein/Coding/rust/noir/test_programs/compile_failure/no_fn_keyword/src/main.nr:2:1
  │
2 │ main() {
  │ ----
  │

Aborting due to 1 previous error
```

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** 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.

---------

Co-authored-by: jfecher <[email protected]>
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jan 25, 2024
michaelelliot pushed a commit to Swoir/noir_rs that referenced this issue Feb 28, 2024
…col#3649)

Fix a part of the problem highlighted by AztecProtocol#3630 

Also created 
* noir-lang/noir#3768
* [Discussion to see why we prioritise Aztec-nr issues over noir syntax
issues. E.g. if we have storage and a syntax error in a method, instead
of showinf the syntax error, we say "no
compute_note_hash_and_nullifier()
found"](https://aztecprotocol.slack.com/archives/C03P17YHVK8/p1702312023384759)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants