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

Single digit hex literals result in an InvalidIntegerLiteral error #3235

Closed
jfecher opened this issue Oct 20, 2023 · 3 comments · Fixed by #3747
Closed

Single digit hex literals result in an InvalidIntegerLiteral error #3235

jfecher opened this issue Oct 20, 2023 · 3 comments · Fixed by #3747
Assignees
Labels
bug Something isn't working

Comments

@jfecher
Copy link
Contributor

jfecher commented Oct 20, 2023

Aim

Writing 0x4 in a program

Expected Behavior

The integer 4

Bug

error: InvalidIntegerLiteral : "0x4" is not a integer
   ┌─ /../short/src/main.nr:35:9
   │
35 │         0x4
   │         ---
   │

To Reproduce

Installation Method

None

Nargo Version

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@jfecher jfecher added the bug Something isn't working label Oct 20, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Oct 20, 2023
@jfecher jfecher self-assigned this Oct 20, 2023
@jfecher jfecher changed the title Single digit hex literals do not work Single digit hex literals result in an InvalidIntegerLiteral error Oct 20, 2023
@jfecher
Copy link
Contributor Author

jfecher commented Oct 20, 2023

This error also looks like it was never meant to be shown - we should not display the actual error kind InvalidIntegerLiteral to the user.

@VictoriaGrasshopper
Copy link

VictoriaGrasshopper commented Nov 13, 2023

It looks like this error happens not only with single digit hex literals, but with an odd amount of symbols in hex literals.
image

As I understood that the problem lies in this code fragment (probably, hex::decode() couldn't parse such values):
https://github.com/noir-lang/noir/blob/master/acvm-repo/acir_field/src/generic_ark.rs#L267

@sambarnes
Copy link
Contributor

@jfecher i took a stab at this over coffee this morning^

thanks for the pointer on code loc here @VictoriaGrasshopper 🙏 👑

github-merge-queue bot pushed a commit that referenced this issue Dec 9, 2023
# Description

single digit (or generally, odd length) hex literals such as `0x4`
result in an `InvalidIntegerLiteral` error

## Problem\*

Resolves #3235

## Summary\*

i just prefixed all odd-length hex literals with another `0`, happy to
change course if there's a better/more efficient way here (i'm kinda
rust noob)

## 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.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Dec 9, 2023
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
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants