leafo / scssphp

SCSS compiler written in PHP
MIT License
1.34k stars 214 forks source link

Infinite loop when extending pseudo selectors #634

Closed cyberalien closed 5 years ago

cyberalien commented 5 years ago

This code is bugged, but it is what it is. Instead of throwing error message compiler falls into infinite loop when parsing this code:

%icon-image {
  &:after {
    color: red;
  }
  &:hover:after {
    color: blue;
  }
}

.icon-members {
  @extend %icon-image;
  &:before {
    @extend .icon-members:after;
  }
}

ul.linklist.bulletin > li.small-icon.icon-members:before {
  @extend .icon-members:before;
}

Recursion happens in function matchExtends() that calls itself near end of function.

Ruby version just compiled that code and showed notice:

DEPRECATION WARNING on line 18 of test.scss:
Extending a compound selector, .icon-members:before, is deprecated and will not be supported in a future release.
Consider "@extend .icon-members, :before" instead.
See http://bit.ly/ExtendCompound for details.