Skip to content

[BUG] Escaping '"' in string in interpolation fails assertion #461

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

Closed
JohelEGP opened this issue May 20, 2023 · 2 comments · Fixed by #464
Closed

[BUG] Escaping '"' in string in interpolation fails assertion #461

JohelEGP opened this issue May 20, 2023 · 2 comments · Fixed by #464
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

Title: Escaping '"' in string in interpolation fails assertion.

Minimal reproducer (https://cpp2.godbolt.org/z/vYsh34z5K):

main: () = {
  std::cout << "\"\"" << '\n'; // Prints `""`.
  std::cout << $R"("")" << '\n'; // Prints `""`.
  std::cout << "\"(\"\")$\"" << '\n'; // Prints `""`.
  std::cout << "(\"\\\"\\\"\")$" << '\n'; // cppfront asserts.
}
Commands:
cppfront -clean-cpp1 main.cpp2

Expected result:

A diagnostic, or to print "" like the other lines.

Actual result and error:

cppfront: source/lex.h:437: std::string cpp2::expand_string_literal(std::string_view, std::vector<error_entry>&, source_position): Assertion `pos == length-1 && text[pos] == '"'' failed.
@JohelEGP JohelEGP added the bug Something isn't working label May 20, 2023
@hsutter
Copy link
Owner

hsutter commented May 20, 2023

@filipsajdak I think you looked at this code last -- can you take a look at this issue?

@filipsajdak
Copy link
Contributor

I am on it.

filipsajdak added a commit to filipsajdak/cppfront that referenced this issue May 22, 2023
The current change iterate over entire string end removes extra backslashes
that are used to indicate escape sequence.

Closes hsutter#461
filipsajdak added a commit to filipsajdak/cppfront that referenced this issue May 22, 2023
The current change iterate over entire string end removes extra backslashes
that are used to indicate escape sequence.

Closes hsutter#461
filipsajdak added a commit to filipsajdak/cppfront that referenced this issue May 23, 2023
The current change iterate over entire string end removes extra backslashes
that are used to indicate escape sequence.

Closes hsutter#461
filipsajdak added a commit to filipsajdak/cppfront that referenced this issue May 23, 2023
The current change iterate over entire string end removes extra backslashes
that are used to indicate escape sequence.

Closes hsutter#461
hsutter pushed a commit that referenced this issue May 29, 2023
The current change iterate over entire string end removes extra backslashes
that are used to indicate escape sequence.

Closes #461
zaucy pushed a commit to zaucy/cppfront that referenced this issue Dec 5, 2023
The current change iterate over entire string end removes extra backslashes
that are used to indicate escape sequence.

Closes hsutter#461
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
None yet
Development

Successfully merging a pull request may close this issue.

3 participants