Skip to content

Error when using function return value as a function argument #1969

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

Closed
bezidejni opened this issue Mar 31, 2016 · 5 comments
Closed

Error when using function return value as a function argument #1969

bezidejni opened this issue Mar 31, 2016 · 5 comments

Comments

@bezidejni
Copy link

I'm experiencing an error that seems to be a regression introduced in version 3.3.3, the code below works fine in 3.3.2:

$base-text-color: #666;

@function calcNavbarTextColor ($base-text-color) {
        @return $base-text-color;
}

$header-text-color: calcNavbarTextColor($base-text-color);

.test_class {
        color: lighten($header-text-color, 20%);
}

This is the output I'm getting:

edxapp@precise64:~/themes/academy$ sassc test.scss
sassc: error: Error: argument `$color` of `lighten($color, $amount)` must be a color

       Backtrace:
        test.scss:10, in function `lighten`
        test.scss:10
        on line 10 of test.scss
>>  color: lighten($header-text-color, 20%);
   --------^

edxapp@precise64:~/themes/academy$ sassc --version
sassc 0.10.1
@bezidejni bezidejni changed the title Error when using when using function return value as a function argument Error when using function return value as a function argument Mar 31, 2016
@mgreter mgreter added this to the 3.3.5 milestone Mar 31, 2016
@mgreter mgreter self-assigned this Mar 31, 2016
@mgreter
Copy link
Contributor

mgreter commented Mar 31, 2016

The reason this is that your function starts with calc. Calc has a special parser path and we wrongly recognize calcNavbarTextColor as such. Simple fix for now is to change calc prefix to something like get. Sorry about that. Fix and PR is underway.

Maybe if you have time you could come up with a Pull Request for sass-spec, so this doesn't happen again? Would be greatly appreciated!

@haschek
Copy link

haschek commented May 4, 2016

Is this bug really fixed in libsass 3.3.5? I'm using node-sass 3.7.0, it is using Herbie (3.3.6) since node-sass 3.6.0 ... or is this fix not included in libsass 3.3.6?

I get errors related to an own function with the name calc_lineheight. If I rename it to lineheight-calc it works.

$ node-sass --version
node-sass       3.7.0   (Wrapper)       [JavaScript]
libsass         3.3.6   (Sass Compiler) [C/C++]

Error message:

{
  "formatted": "Error: Undefined operation: \"calc_lineheight($text-supercontent-fontsize) lt 1.25\".\n        on line 25 of _devshare/scss/settings/_calculation.scss\n>> @if ($text_supercontent_lineheight < $text_minimal_lineheight)\n   -----^\n",
  "message": "Undefined operation: \"calc_lineheight($text-supercontent-fontsize) lt 1.25\".",
  "column": 6,
  "line": 25,
  "file": "/data/_devshare/scss/settings/_calculation.scss",
  "status": 1
}

As I wrote before, that error do not occure if I rename the function to lineheight-calc, so the error seems not to be on my side.

@xzyfer
Copy link
Contributor

xzyfer commented May 5, 2016

@haschek Test your code against Ruby Sass 3.4.x on Sassmiester to confirm your Sass is valid. Looks like a bug in your code.

@haschek
Copy link

haschek commented May 6, 2016

@xzyfer Maybe I approve it with SassMeister later but my Sass code worked for last three years, I do not see the bug there.

It stopped working with the change to node-sass 3.7.0 (libsass 3.3.6) and worked again after a simple renaming of the calc_lineheight function to lineheight-calc. It's not necessary bug #1969 but it looks like it has something to do with the calc prefix.

@xzyfer
Copy link
Contributor

xzyfer commented May 10, 2016

@haschek without a copy-pastable code sample I cannot confirm you issue. If you think there is a bug please create new issue with enough code for me to see this error myself.

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

4 participants