-
Notifications
You must be signed in to change notification settings - Fork 193
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
Fix un-parenthesized nested operation via a variable (Less.js 4.1.1) #114
Comments
We'll need a reduced example input that reproduces the error to investigate. I suggest comparing also to upstream Less.js at http://lesscss.org/less-preview/, to see how the same input behaves there. |
I've isolated the problem to this example: p {
@a: 20px / 2;
margin: 2 * @a;
} It does not work even with Less.js. I think it's because the expression p {
@a: (20px / 2);
margin: 2 * @a;
} |
@peterpp Good catch. Note that, while it is not recommended, it is possible to set div {
border-radius: 40px / 10px;
grid-column: 1 / -1;
font: 12px/1.6 sans-serif;
background: left 5% / 15% url(images/star.png);
}
If you're okay with requiring a https://lesscss.org/usage/#less-options-math By default, upstream Less.js indeed also crashes: ![]() But, Less.js with math=always (Example in the Less.js playground): This works without an error. The main reason that this feature exists, is for backwards-compatibility with Less.js 1.x and Less.js 2.x, where slash without parenthesis was the default. Back then, there were not many CSS features that used a slash. Once this became more common, upstream decided to change this, and hence nowadays parenthesis are required for division.
I still think there is a bug here, because this is not failing with a user-facing Less.php error about an invalid operation in Less syntax. Instead, it is failing the PHP level due to a mistake in our internal code. Even though it is invalid, we should be able to detect that it is invalid and say so explicitly instead of crashing in this way. |
Also present in less.js with 3.13.1 Fixed in less.js with less/less.js#3589, that is 4.1.1 |
´Undefined property: Less_Tree_Operation::$value
with v5.1.1 on PHP 8.3
Issue imported to https://phabricator.wikimedia.org/T386074. Fixed in 3c9452e / https://gerrit.wikimedia.org/r/c/mediawiki/libs/less.php/+/1121472. |
I see
Fun fact: At this point
$other
is no the expectedLess_Tree_Dimension
but an instance ofLess_Tree_Operation
(type safety would be great).I would love to help debugging this, but I can't even tell if this can be caused by faulty LESS input (it should not lead to such a warning, though) or is a programmatic error.
The text was updated successfully, but these errors were encountered: