Skip to content

unary dash in @mixin uses same value every @include #2975

@schl3ck

Description

@schl3ck

Hi,

I've noticed that the unary dash - with a string in a mixin always uses its first computed value in the following calls. Note the recurring .test-b-asdf rule in the actual results.

LibSass processes @include test("foo2"); by removing the quotes in the output, in contrast to dart-sass which outputs an error. Because of this the two lines are commented out below.

Tested locally and with https://www.sassmeister.com/

input.scss

@mixin test($name: false) {
    $a: "";
    $b: "";
    @if $name {
        $a: "-#{$name}";    // works as expected
        $b: -$name;         // here occurs the bug
    } @else {
        $a: "";
        $b: "";
    }
    
    .test-a#{$a} {
        display: block;
    }
    .test-b#{$b} {
        display: block;
    }
}

@include test;
@include test(asdf);
@include test(foo1);
@include test(bar1);
// @include test("foo2");
// @include test("bar2");

Actual results

libsass 3.5.4

.test-a {
  display: block;
}

.test-b {
  display: block;
}

.test-a-asdf {
  display: block;
}

.test-b-asdf {
  display: block;
}

.test-a-foo1 {
  display: block;
}

.test-b-asdf {
  display: block;
}

.test-a-bar1 {
  display: block;
}

.test-b-asdf {
  display: block;
}

Expected result

dart-sass 1.12.0

.test-a {
  display: block;
}

.test-b {
  display: block;
}

.test-a-asdf {
  display: block;
}

.test-b-asdf {
  display: block;
}

.test-a-foo1 {
  display: block;
}

.test-b-foo1 {
  display: block;
}

.test-a-bar1 {
  display: block;
}

.test-b-bar1 {
  display: block;
}

Version info

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

OS: Windows 10 Enterprise 1803 x64
Environment: node.js v6.16.0

Thank you!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions