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

Infinite loop in error message #31

Closed
benjaminwinger opened this issue Sep 26, 2021 · 2 comments
Closed

Infinite loop in error message #31

benjaminwinger opened this issue Sep 26, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@benjaminwinger
Copy link
Contributor

When parsing this file and displaying an error message related to the string err-😂 via lexy_ext::report_error, the output is 12 │ err-⟨U+????⟩⟨U+????⟩, but with the ⟨U+????⟩ repeated for, at the very least, a long time.

I've also tried it with a few other unicode characters and gotten the same result.

@foonathan
Copy link
Owner

As a temporary fix, you can apply the following diff:

diff --git a/include/lexy/visualize.hpp b/include/lexy/visualize.hpp
index 1ad79fe9..1a12f3cb 100644
--- a/include/lexy/visualize.hpp
+++ b/include/lexy/visualize.hpp
@@ -392,7 +392,8 @@ OutputIt visualize_to(OutputIt out, lexy::lexeme<Reader> lexeme,
         {
             lexy::engine_cp_auto::error_code ec{};
             auto                             cp = lexy::engine_cp_auto::parse(ec, reader);
-            if (ec == lexy::engine_cp_auto::error_code::eof)
+            if (ec != lexy::engine_cp_auto::error_code{}
+                && !lexy::engine_cp_auto::recover(reader, ec))
                 break;
 
             out = visualize_to(out, cp, opts);

I'm not quite happy with the way the error message is rendered (it will split the code point in half and report multiple invalid ones for each byte, as only some code units are underlined), so I'll need to take some time to come up with a proper fix.

foonathan added a commit that referenced this issue Oct 7, 2021
Each byte is rendered in the output.

Fixes #31.
foonathan added a commit that referenced this issue Oct 7, 2021
foonathan added a commit that referenced this issue Oct 7, 2021
Each byte is rendered in the output.

Fixes #31.
foonathan added a commit that referenced this issue Oct 7, 2021
foonathan added a commit that referenced this issue Oct 7, 2021
Each byte is rendered in the output.

Fixes #31.
foonathan added a commit that referenced this issue Oct 7, 2021
foonathan added a commit that referenced this issue Oct 7, 2021
Each byte is rendered in the output.

Fixes #31.
foonathan added a commit that referenced this issue Oct 7, 2021
foonathan added a commit that referenced this issue Oct 7, 2021
Each byte is rendered in the output.

Fixes #31.
foonathan added a commit that referenced this issue Oct 7, 2021
foonathan added a commit that referenced this issue Oct 7, 2021
Each byte is rendered in the output.

Fixes #31.
foonathan added a commit that referenced this issue Oct 7, 2021
foonathan added a commit that referenced this issue Oct 7, 2021
Each byte is rendered in the output.

Fixes #31.
foonathan added a commit that referenced this issue Oct 7, 2021
foonathan added a commit that referenced this issue Oct 7, 2021
Each byte is rendered in the output.

Fixes #31.
foonathan added a commit that referenced this issue Oct 7, 2021
foonathan added a commit that referenced this issue Oct 7, 2021
@foonathan
Copy link
Owner

This is now fixed, and it should report an error looking like this: https://lexy.foonathan.net/playground/?id=nEa7KjabK&mode=tree

tustin2121 pushed a commit to tustin2121/fluent-cpp that referenced this issue Mar 15, 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
None yet
Development

No branches or pull requests

2 participants