less.js
less.js copied to clipboard
Cannot consume `@rest...` when not specified
To reproduce:
.foo(@a, @rest...) {
.bar(@a, @rest);
}
.bar(@a, @b: false) {}
.foo(@a, true); // works
.foo(@a); // Cannot read properties of undefined (reading 'value')
Current behavior:
Consuming an optional variadic that is not set causes an error.
Expected behavior:
Since (@a, @rest...) supports 1..N arguments, it should be expected that in the 1 case, @rest is unset, and if so, passing @rest should be valid and a no-op instead of an error.
Environment information:
-
lessversion: 4.4.0 -
nodejsversion: v22.12.0 -
operating system: 6.6.87.2-microsoft-standard-WSL2
You'd have to define @a at least, but this Less
.foo(@a, @rest...) {
.bar(@a, @rest...);
}
.bar(@a, @b: false) { div { color: @b; } }
@a: 1;
.foo(@a);
gives me:
div {
color: false;
}
in version 4.4.0.
Ah, well you changed the calling convention from @rest to @rest..., which is presumably how you're supposed to do it, but this is not documented anywhere.