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 and modifying arglist across mixins (Sass v3.5.0, Libsass v3.5.0, 3.5.0.beta.3-54-gdebb1e32 bug?) #2480

Closed
bencergazda opened this issue Oct 3, 2017 · 1 comment

Comments

@bencergazda
Copy link

bencergazda commented Oct 3, 2017

Reduced test case: https://www.sassmeister.com/gist/44340f52a27ad3e4fe61c9772de66d4f

Simplified: I have three mixins:

  • a main with a few arguments
  • a router, which calls the appropriate main mixin, depending on the situation
  • a helper, which calls the original mixin (through the router mixin) with predefined arguments.

It works when I do not use named argument in the helper mixin, but if so, fails on Sass v3.5.0.pre.rc.1 and LibSass v3.5.0.beta.2, 3.5.0.beta.3-54-gdebb1e32.

Works ok in every cases with other Sass versions: Sass v3.3.14, Sass v3.4.21, Sass 4.0.0.alpha.1

Should I do something otherwise?

input.scss

@mixin main(
  $param1: param1,
  $param2: param2,
  $param3: param3
) {
  param1-value: $param1;
  param2-value: $param2;
  param3-value: $param3;
}

@mixin router($args...) {
  @if (true) { @include main($args...) }
  @else { @include main2($args...) }
}

@mixin helper($args...) {
  @include router($param2: param__2, $args...)
}

.ordinal-arguments {
  /* OK - gets $param2 value from @mixin helper and has the correct $param1 value */
  @include helper(param___1);
}

.named-arguments {
  /* OK on Sass v3.3.14, Sass v3.4.21, Sass 4.0.0.alpha.1,
  but fails on Sass v3.5.0.pre.rc.1 and LibSass v3.5.0.beta.2,
  (gets $param2 value from @mixin helper, but $param1 has only its default value.)
  
  (Note: It works on Sass v3.5.0.pre.rc.1 and LibSass v3.5.0.beta.2, when: 
    - in @mixin helper I call "main" instead of "router" (line 17)
    - or if I do not edit the value of $param 2 (line 17) ) */
  @include helper($param1: param___1);
}

Actual results

LibSass v3.5.0.beta.2

/* param1-value should be 'param___1' and param2-value should be param__2 in both cases */
.ordinal-arguments {
  /* OK - gets $param2 value from @mixin helper and has the correct $param1 value */
  param1-value: param___1;
  param2-value: param__2;
  param3-value: param3;
}

.named-arguments {
  /* OK on Sass v3.3.14, Sass v3.4.21, Sass 4.0.0.alpha.1,
  but fails on Sass v3.5.0.pre.rc.1 and LibSass v3.5.0.beta.2,
  (gets $param2 value from @mixin helper, but $param1 has only its default value.)
  
  (Note: It works on Sass v3.5.0.pre.rc.1 and LibSass v3.5.0.beta.2, when: 
    - in @mixin helper I call "main" instead of "router" (line 17)
    - or if I do not edit the value of $param 2 (line 17) ) */
  param1-value: param1;
  param2-value: param__2;
  param3-value: param3;
}

Expected result

ruby sass 3.4.21

/* param1-value should be 'param___1' and param2-value should be param__2 in both cases */
.ordinal-arguments {
  /* OK - gets $param2 value from @mixin helper and has the correct $param1 value */
  param1-value: param___1;
  param2-value: param__2;
  param3-value: param3;
}

.named-arguments {
  /* OK on Sass v3.3.14, Sass v3.4.21, Sass 4.0.0.alpha.1,
  but fails on Sass v3.5.0.pre.rc.1 and LibSass v3.5.0.beta.2,
  (gets $param2 value from @mixin helper, but $param1 has only its default value.)
  
  (Note: It works on Sass v3.5.0.pre.rc.1 and LibSass v3.5.0.beta.2, when: 
    - in @mixin helper I call "main" instead of "router" (line 17)
    - or if I do not edit the value of $param 2 (line 17) ) */
  param1-value: param___1;
  param2-value: param__2;
  param3-value: param3;
}

version info:

var sass = require('node-sass');
console.log(sass.info);

node-sass    4.5.3   (Wrapper)       [JavaScript]
libsass         3.5.0.beta.2    (Sass Compiler) [C/C++]
@bencergazda
Copy link
Author

bencergazda commented Oct 9, 2017

The strange thing is that when nex3 tested locally, got the good results in 3.4.25, 3.5.0-rc.1, 3.5.1, 4.0.0.alpha.1, and bleeding edge 4.0.0. Can I hope that this has been already fixed or should I provide any extra detail?

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