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

Passing an arglist to core-function calls will fail in certain cases #2472

Closed
mirisuzanne opened this issue Aug 24, 2017 · 3 comments
Closed

Comments

@mirisuzanne
Copy link

mirisuzanne commented Aug 24, 2017

I get different errors depending on the number of arguments accepted by the internal function - but the issue seems the same. There is no error when directly calling these functions with similar manually-constructed list-arguments, or when calling custom defined functions. The error only occurs when passing an arglist from a custom mixin/function along to an internal function…

Here, I'm calling adjust-color with only one of the many optional arguments:

@function adjust(
  $color,
  $args...
) {
  // not enough arguments for `adjust-color' on line x at column y
  @return call('adjust-color', $color, $args...);

  // this hack seems to fix the problem…
  $hack: join(('adjust-color', $color), $args);
  @return call($hack...);
}

.test {
  color: adjust(#102030, -5);
}
/* expected result */
.test {
  color: #0b2030;
}

When you pass in the exact number of arguments required, the error is slightly different - but the same hack works:

@function dark(
  $color,
  $args...
) {
  // argument `$amount` of `darken($color, $amount)` must be a number
  @return call('darken', $color, $args...);

  // this hack seems to fix the problem…
  $hack: join(('darken', $color), $args);
  @return call($hack...);
}

.test {
  color: dark(#102030, 5%);
}
/* expected result */
.test {
  color: #0a131d;
}

This seems to be true in all versions of Libsass, but not in Ruby Sass. There's a demo on sassmeister, since libsass.ocbnet.ch won't allow me to bookmark this.

I'll add these tests to the spec, and comment with a link…

@mgreter
Copy link
Contributor

mgreter commented Nov 11, 2017

@mirisuzanne this seems to error in ruby sass now:

Error: -5 is not a keyword argument for `adjust_color'
        on line 6 of 2472.scss

Can you still somehow reproduce this issue?

@mgreter
Copy link
Contributor

mgreter commented Nov 12, 2017

Closing as this seem to be invalid syntax as confirmed with ruby sass and dart sass. Please re-open if you can reproduce the issue. Thanks!

@mgreter mgreter closed this as completed Nov 12, 2017
@mirisuzanne
Copy link
Author

It seems that one of my examples was bad, but the other still shows the same discrepancy. I removed the error: https://www.sassmeister.com/gist/cd09d650328b8f486a5d3b31c3009225

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants