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

Bug when using the plus symbol on calc calls inside from expressions for colors #4316

Open
filipesabella opened this issue Feb 18, 2025 · 1 comment
Labels

Comments

@filipesabella
Copy link

filipesabella commented Feb 18, 2025

To reproduce:

div {
  background: rgb(from blue calc(r + 100) g b);
}

Current behavior:

Less throws a Could not parse call arguments or missing ')' error.

Expected behavior:

Should generate:

div {
  background: rgb(from blue calc(r + 100) g b);
}

Environment information:

Running on the official playground is enough to reproduce it:
https://lesscss.org/less-preview

Subtraction works just fine:

div {
  background: rgb(from blue calc(r - 100) g b);
}

I also found another bug that might be related. Notice the inversion from r - 100 to 100 - r:

div {
  background: rgb(from blue calc(100 - r) g b);
}

Drops the math operator:

div {
  background: rgb(from blue calc(100  r) g b);
}
Copy link

dosubot bot commented Feb 18, 2025

Hey @filipesabella! 👋 I'm here to help you with any bugs, questions, or contributions you have in mind. Let's squash those bugs together!

The issue you're encountering seems to be related to how Less handles parsing of calc expressions within from color functions. Specifically, it appears that Less is having trouble parsing the + operator within calc() when used in this context, resulting in a parsing error.

Currently, Less does not evaluate math expressions directly within calc() for CSS compatibility, but it does allow for the inclusion of variables and nested math operations within its expression [1]. However, it seems that the + operator is causing a parsing issue in this specific scenario.

As a workaround, you might consider restructuring your code to avoid using the + operator directly within calc() in from expressions, or explore alternative ways to achieve the desired effect without triggering the parsing error.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant