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

Infinite loop with multiple @extends in 2.4.0 #213

Open
pmusaraj opened this issue Aug 24, 2020 · 0 comments
Open

Infinite loop with multiple @extends in 2.4.0 #213

pmusaraj opened this issue Aug 24, 2020 · 0 comments

Comments

@pmusaraj
Copy link

pmusaraj commented Aug 24, 2020

We upgraded from 2.0.1 to 2.4.0 and ran into a strange issue with a Sassc process going into an infinite loop on one specific stylesheet. I stripped down the stylesheet to its bare minimum to have the following minimal repro:

require 'sassc'

sass = <<SCSS

// Administrative buttons
.btn {
  // Buttons with no extra styles
  &.-flat {
    border: none;

    &,
    &:hover {
      background: transparent;
    }
  }
}

//
// UI Button Corrections
// ---------------------

// "New Topic" button
.btn#create-topic {
  @extend .btn-secondary;
  @extend .btn.-no-icon;
}

// "Create Topic" button
.btn.create,
.btn.edit-category {
  @extend .btn.-no-icon;
}

// Button to load more topics on homepage
.more-topics {
  .btn {
    @extend .btn.-small;
  }
}

// Topic footer buttons
#topic-footer-buttons {
  > button {
    @extend .btn.-flat;
  }

  > .btn-primary {
    @extend .btn-secondary;
  }
}

// Notification options
.notification-options {
  .btn {
    @extend .btn.-flat;
  }
}

// Extra post options
.topic-map {
  .buttons {
    .btn {
      @extend .btn.-flat;
    }
  }
}
SCSS

result = SassC::Engine.new(sass, style: :compressed).render
puts result.inspect

When I run the above, the process never completes and the CPU goes through the roof. Removing only the last @extend results in the following output:

Traceback (most recent call last):
	2: from sass.rb:72:in `<main>'
	1: from /Users/pmusaraj/.gem/ruby/2.6.5/gems/sassc-2.4.0/lib/sassc/engine.rb:50:in `render'
stdin:34: Error: The target selector was not found. (SassC::SyntaxError)
       Use "@extend .-small !optional" to avoid this error.
        on line 34 of stdin
>>     @extend .btn.-small;

Note that I am fully aware the SCSS syntax above is wrong, but shouldn't this return the error message at all times, no matter how many occurrences of the broken @extends are used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant