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

Format and raw strings ignore escape characters #4642

Closed
michaeljklein opened this issue Mar 26, 2024 · 1 comment · Fixed by #6703
Closed

Format and raw strings ignore escape characters #4642

michaeljklein opened this issue Mar 26, 2024 · 1 comment · Fixed by #6703
Assignees
Labels
bug Something isn't working

Comments

@michaeljklein
Copy link
Contributor

Aim

Attempted to use escape characters in format or raw strings

Expected Behavior

  1. reject invalid escape character \999..
  2. convert escaped characters to expected values, e.g. \n becoming a newline
  3. the same behavior between the different string types, besides exceptions for formatting and #'s

Bug

Format strings f".." and raw strings r".." currently ignore \n, and other escaped characters.

For example:

    print(f"hello world!\n \0 \99999999");
    print(r#"hello world!\n \0 \99999999"#);

nargo execute gives:

hello world!\n \0 \99999999[name_of_program] Circuit witness successfully solved

To Reproduce

  1. put one of the print's above into a test file
  2. nargo execute

Project Impact

None

Impact Context

No response

Workaround

Yes

Workaround Description

use regular strings for escaped characters and format strings for formatting, like so:

  print(f"hi there, {name}!");
  print("\n");

Additional Context

No response

Installation Method

Binary (noirup default)

Nargo Version

No response

NoirJS Version

0.24.0+722dc969e8b09e5a6fd56b094b6939e9330233f6

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@michaeljklein michaeljklein added the bug Something isn't working label Mar 26, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Mar 26, 2024
@asterite asterite self-assigned this Dec 4, 2024
@asterite
Copy link
Collaborator

asterite commented Dec 5, 2024

This will be fixed by #6703

I'm commenting this because it will only "fix" it for fmtstring. Raw strings seem to work well... or at least in Rust if you do "\n" inside a raw string, it prints "\n", not a newline, and it seems escape chars don't work inside raw strings.

@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Dec 6, 2024
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
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants