Skip to content

[FIX] preserving parens for std::cout expressions #92

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

Merged
merged 1 commit into from
Oct 23, 2022

Conversation

filipsajdak
Copy link
Contributor

There is a bug in expressions inside std::cout shift expressions. The example is in regression-tests/mixed-test-parens.cpp2

The code:

std::cout << (1+2)*(3+v[0]);

currently compiles to

std::cout << (1+2)* 3+v[0];

After this change the cppfront preserves the parens and returns:

std::cout << (1+2)*(3+v[0]);

This PR closes #91

@filipsajdak
Copy link
Contributor Author

Probably we need to check if there is more expressions that might suffer from disappearing parens.

@hsutter hsutter merged commit 7a8bc1e into hsutter:main Oct 23, 2022
@hsutter
Copy link
Owner

hsutter commented Oct 23, 2022

Thanks, this looks reasonable. I'm slightly confused because I remember that these parens were correctly emitted (for the first time) with a commit about a week ago. Curious what caused the regression?

@filipsajdak
Copy link
Contributor Author

@hsutter it looks like this test case was broken by my previous PR about parens #67 (that one you refers to). It looks like everything works fine before it. Sorry, my mistake I should have run more regression tests. I already do it before sending PRs (that is why I found this issue).

Previous PR fixes different scenario:

f((i+(i+1)*2)/2);

I will investigate it a little more later.

@filipsajdak filipsajdak deleted the fsajdak-fix-parens-with-std-cout branch October 24, 2022 07:16
@JohelEGP
Copy link
Contributor

The issue had been known since #81. From the CI run:

       Start  72: codegen/check/mixed-test-parens
85/118 Test  #72: codegen/check/mixed-test-parens ................................................***Failed    0.00 sec

Azmah-Bad pushed a commit to Azmah-Bad/cppfront that referenced this pull request Feb 24, 2023
…h-std-cout

[FIX] preserving parens for std::cout expressions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Parens disappear in std::cout expressions
3 participants