Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misslead error message, when function ist not found #1769

Closed
mbihn opened this issue Jul 31, 2022 · 1 comment · Fixed by #1901
Closed

Misslead error message, when function ist not found #1769

mbihn opened this issue Jul 31, 2022 · 1 comment · Fixed by #1901
Assignees
Labels
cosmetic Doesn't affects CSS semantics enhancement

Comments

@mbihn
Copy link

mbihn commented Jul 31, 2022

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.

@nex3 nex3 transferred this issue from sass/sass Aug 2, 2022
@nex3 nex3 added enhancement cosmetic Doesn't affects CSS semantics labels Aug 2, 2022
@nex3
Copy link
Contributor

nex3 commented Aug 2, 2022

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."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cosmetic Doesn't affects CSS semantics enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants