Description
To reproduce:
With strict units enabled, perform a calc
-like expression inside a min
or max
function
and use a CSS variable. E.g.
prop : min(100% - var(--some-var), 10px);
Current behavior:
Compiler will throw "Operation on an invalid type" error.
Expected behavior:
Compiler knows the arguments to min
and max
can be calc
-like and doesn't throw, but retains the arguments as-is.
Environment information:
less
version: 4.1.3nodejs
version: 14operating system
: any
Having dug around a bit, it appears that the root of the issue is the fact that Operation
is visited and flattened before passing to min
and max
, which means the var()
node trips the compiler error as it afaict does not implement an operate
method.
This problem can be avoided by setting evalArgs : false
for both functions and performing custom lazy evaluation inside the functions themselves, where it can be wrapped in a try-catch and cause the function to go inert (and be treated as the CSS function proper) when incompatible types are present.