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

Curly braces of 'else' removed unexpectedly when if-else enclosed in a macro #468

Open
cedarz opened this issue Oct 31, 2024 · 2 comments
Open

Comments

@cedarz
Copy link

cedarz commented Oct 31, 2024

code like this, after processing of shader-minifier, only B is part of else statement, C is out of the scope.

#ifdef OPT
            if (...)
            {
                  A;
            }
            else
#endif
            {   // removed
                 B;
                 C;
            }   // removed
@laurentlb
Copy link
Owner

Handling this kind of macro is tricky.

For a workaround, maybe you can rewrite your code to something like:

            if (OPT && ...)
            {
                  A;
            }
            else
            {
                 B;
                 C;
            }

@cedarz
Copy link
Author

cedarz commented Nov 4, 2024

@laurentlb Thanks for replying. I've used the verbatim workaround in README to solve this.
You said this case is tricky, I agree with it.

But, when a big shader with such case gets processed, it's also trickier to find the error location.
That's why i report it, and expect more advanced and automatic solutions.
Thank you!!

Handling this kind of macro is tricky.

For a workaround, maybe you can rewrite your code to something like:

            if (OPT && ...)
            {
                  A;
            }
            else
            {
                 B;
                 C;
            }

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

No branches or pull requests

2 participants