Misslead error message, when function ist not found
if a function is missed sass does complain about it, but complains that the variables are not a valid CSS value. Typically, this leads to misunderstandings when one of the parameterizers is a map.
Example (from Bootstrap 5.2):
$theme-colors: (
"primary": $primary,
"secondary": $secondary,
"success": $success,
"info": $info,
"warning": $warning,
"danger": $danger,
"light": $light,
"dark": $dark
) !default;
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value") !default;](url)
End up in Error:
Error: ("primary": #007bff, "secondary": #6c757d, "success": #28a745, "info": #17a2b8, "warning": #ffc107, "danger": #dc3545, "light": #f8f9fa, "dark": #343a40) isn't a valid CSS value.
╷
6 │ $theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value") !default;
│ ^^^^^^^^^^^^^
because
@function map-loop($map, $func, $args...) {
$_map: ();
@each $key, $value in $map {
// allow to pass the $key and $value of the map as an function argument
$_args: ();
@each $arg in $args {
$_args: append($_args, if($arg == "$key", $key, if($arg == "$value", $value, $arg)));
}
$_map: map-merge($_map, ($key: call(get-function($func), $_args...)));
}
@return $_map;
}
is missing.
The error message is clearly wrong and confuses the user.
This happens often, if someone mix versions (e.g. Bootstrap) or forget to include all partials or just made a small typing error.
Yeah, it would probably be worth highlighting the function name as well in this case and saying something like "This is interpreted as a plain CSS function. If you intended it to be a Sass function, the definition could not be found."