Closed laino closed 3 years ago
That can't be your only line in the file? Do you have more context?
Nope. That's the only line. It takes just that.
Actually the * 4
isn't even necessary.
Just this is enough:
@c: 1 + 1 / 1;
oopsie whoopsie. other
is {operand: "/", ... }
still when this code is called:
https://github.com/less/less.js/blob/master/packages/less/src/less/tree/dimension.js#L73
This is a bug that just got introduced?
It's a bug that has existed at least since the 4.0.0
release and is still present in 4.1.0
.
It's probably related to the "Parens-division now the default math setting" change.
So it looks like for the above code, Less should be throwing 'Operation on an invalid type'
. See: https://github.com/less/less.js/pull/3589
Less should be throwing 'Operation on an invalid type'
Why?
@RealDolos Because in parens-division
mode (the 4.0 Less default), you're trying to add 1 +
a CSS expression 1 / 1
. The division won't divide; it will be output as is, so you can't add 1 to it.
@RealDolos Now, an argument could be made that just the 1 + 1
should add together in that case, but unfortunately that's not the way it's parsed. As it is, division is parsed as a division operation, even if it's not performed, so when it's not performed, it can't be part of other operations, and should throw an error.
Adding 1 + 1
would be surprising behavior I suppose.
Still, "Operation on an invalid type" is a bit of a shit error message
@RealDolos
Still, "Operation on an invalid type" is a bit of a shit error message
Please be kind. That's the error message thrown on other types if you attempt operations (with like a keyword for example). I only meant it should be throwing a proper error, and that's the current error message for operations.