Skip to content

Mixin overloads from detached ruleset caller scope aren't applied #2556

@SLaks

Description

@SLaks

Source:

.Method() when (default()) {
  content: 'Not inverted';
}

.CallInverted(@callback) {
  @invert: true;
  @callback();

  .Method() when (@invert) {
    content: 'Inverted';
  }
}

.Call(@callback) {
  @invert: false;
  @callback();
}


a {
  .CallInverted({ .Method(); });
}

b {
  .Call({ .Method(); });
}

c {
  .Method();
}

Current Output:

a {
  content: 'Not inverted';
}
b {
  content: 'Not inverted';
}
c {
  content: 'Not inverted';
}

Desired Output:

a {
  content: 'Inverted';
}
b {
  content: 'Not inverted';
}
c {
  content: 'Not inverted';
}

Context: I want to make a set of mixins that are sometimes called in callbacks, and I want to make each one use a different definition from some callsites of the callbacks (the .CallInverted() mixin).

I can't find any other way to do this, because the guard variable must be defined when called in global scope, and I can't override its value when called from a mixin.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions