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

invalid operands for multiplication - once again #1207

Closed
DenisMir opened this issue May 14, 2015 · 8 comments
Closed

invalid operands for multiplication - once again #1207

DenisMir opened this issue May 14, 2015 · 8 comments

Comments

@DenisMir
Copy link

At the moment I am using the following setup: grunt-sass@1.0.0, node-sass@3.1.0 and libsass@3.2.4 and getting once again the "invalid operands for multiplication". This error was not there with libsass@3.2.0-beta6. I can't even give you the correct error description since it errors out with Line 36 Column 13 which is a normal comment block.

@DenisMir DenisMir changed the title invalid operands for multiplication invalid operands for multiplication - once again May 14, 2015
@xzyfer
Copy link
Contributor

xzyfer commented May 14, 2015

@DenisMir I'm sorry but without a copy-pastable code sample we cannot begin to investigate this issue. Please take the time to find what part of your code is causing this issue.

@DenisMir
Copy link
Author

@xzyfer
I have tried to hunt down the issue. I'm pretty sure I got it now but it is pretty weird.

I have some function which is reading a modular scale value from a map.

@function ms-get-scale-ratio($pos) {
  @if not $modular-scale {
    @warn 'Please define a modular scale map in your config.';
  } @else {
    $key: scale-#{$pos};
    @debug 'Trying to get ratio for position #{$pos} with key #{$key}';
    $ratio: map-get($modular-scale, $key);
    @debug 'Found ratio is #{$ratio}';
    @return $ratio;
  }
}

The modular scale map is something like that:

$modular-scale: (
  scale-0: 1.2,
  scale-1: 1.3,
  scale-2: 1.4,
  scale-3: 1.5,
  scale-4: 1.6
);

The part where the function gets called looks like:

$bp-index: str_slice($bp-key, 7);
@debug 'Got breakpoint index #{$bp-index} for #{$bp-key}';
$ratio: ms-get-scale-ratio($bp-index);

Now when I'm looking at the debug log I'm getting some correct pairs of log which look like:

Got breakpoint index 2 for break-2
Trying to get ratio for position 2 with key scale-2
Found ratio is 1.4

But I'm also getting something like:

Got breakpoint index 2 for break-2
Trying to get ratio for position "2" with key scale-"2"
Found ratio is

The "2" is breaking the code here. With no ratio value I'm getting the invalid operands for multiplication which is ok.

I hope that I could help you finding the issue. Please adjust the title according to the correct malfunction. At the moment I'm not quite sure what is going on here. If you need more information just drop me a message.

@DenisMir
Copy link
Author

@xzyfer Do you need more information from me to be able to identify the bug?

@xzyfer
Copy link
Contributor

xzyfer commented May 31, 2015

@DenisMir the quickest way for use to address this issue is if you create a http://sassmeister.com gist showing the problem.

We simply don't have the time to reconstruct the code to test every bug.

@DenisMir
Copy link
Author

DenisMir commented Jun 3, 2015

@xzyfer No problem. I will try to reproduce the bug there. I haven't seen it since using node-sass@3.1.2 in grunt-sass.

@KittyGiraudel
Copy link

Reduced test case:

@function test($pos) {
  @return test-#{$pos};
}

.foo {
  content: test(str-slice('scale-0', 7));   // Nope
  content: test-#{str-slice('scale-0', 7)}; // Yep
}

Expected

.foo {
  content: test-0;
  content: test-0;
}

Actual

.foo {
  content: test-"0";
  content: test-0;
}

@mgreter
Copy link
Contributor

mgreter commented Jun 12, 2015

Fix seems to be simple (in bind.cpp):

for (size_t i = 0, L = as->length(); i < L; ++i) {
  if (auto str = dynamic_cast<String_Quoted*>((*as)[i]->value())) {
    // force optional quotes (only if needed)
    if (str->quote_mark()) str->quote_mark('*');
  }
}

@xzyfer: I already have this in my latest (local) refactoring branch which I will updatein a few hours/days!

@mgreter
Copy link
Contributor

mgreter commented Jul 13, 2015

We now have a passing spec test since #1249 was merged 🎈

@mgreter mgreter closed this as completed Jul 13, 2015
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