less.js
less.js copied to clipboard
less parse about inconsistent operation performance
To reproduce:
// parse ok
@c:20px + 20px * 2px;
.d {
font-size: @c;
}
// parse ok
@c:20px + (20px * 2px);
.d {
font-size: @c;
}
// parse fail
@c:20px + 20px / 2px;
.d {
font-size: @c;
}
// parse ok
@c:20px + (20px / 2px);
.d {
font-size: @c;
}
Current behavior:
less.js the operation of variables is inconsistent in multiplication and division
Expected behavior:
consistent behavior
Environment information:
-
less
version: 3.13.0 -
nodejs
version: 16.13 -
operating system
: darwin
please do not forcibly close issue
I'm trying to fix this issue, there have been many discussions about math rules in less. This is an issue of historical discussions https://github.com/less/less.js/issues/1880
I found in the documentation the new operation description in less 4
https://github.com/less/less-docs/blob/master/content/usage/less-options.md
Another issue also verified my view
https://github.com/less/less.js/issues/3586
My understanding is that, we should throw error in there 7 situations.
// parse fail
@c:20px + 20px / 2px;
// parse fail
@c:20px - 20px / 2px;
// parse fail
@c:20px / 20px / 2px;
// parse fail
@c:20px * 20px / 2px;
// parse fail
@c:20px / 20px + 2px;
// parse fail
@c:20px /20px - 2px;
// parse fail
@c:20px / 20px * 2px;
I'm not sure my understanding is correct. I need your advice to modify pr. @matthew-dean @iChenLei
Yes, the failures are expected in the current Less math mode. See: https://github.com/less/less-docs/blob/master/content/usage/less-options.md#math