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

The method invalid_content_parent is never called #2106

Closed
marianposaceanu opened this issue Jul 26, 2016 · 6 comments
Closed

The method invalid_content_parent is never called #2106

marianposaceanu opened this issue Jul 26, 2016 · 6 comments
Labels
bug Something isn't working

Comments

@marianposaceanu
Copy link

marianposaceanu commented Jul 26, 2016

So I was investigation why using libsassc I was getting:

SassC::SyntaxError: Error: Mixin "something" does not accept a content block.

which is completely valid since something doesn't use @content.

https://github.com/sass/libsass/blob/master/src/expand.cpp#L666


Yet on the Ruby side nothing is reported and whilst reading a bit the code:

This method should set has_content to true:

https://github.com/sass/sass/blob/stable/lib/sass/tree/visitors/check_nesting.rb#L82

but it doesn't seem to be called anywhere.

Hence this logic won't raise an exception if the mixin has no @content:

https://github.com/sass/sass/blob/stable/lib/sass/tree/visitors/perform.rb#L354

@chriseppstein
Copy link

I need to see a Sass source code example for this.

@chriseppstein chriseppstein added the needs info Blocked on user response label Jul 27, 2016
@marianposaceanu
Copy link
Author

marianposaceanu commented Jul 27, 2016

Ok the bug is quite an edge case it seems libsassc is much more strict:

@mixin breakpoint($args: null) {
  //  CASE IF NO DATA IS PASSED WE SHALL OUTPUT MEDIA QUERY ONLY FOR SCREEN THIS MEANS STYLES WILL BE GLOBALLY AND INHERITABLE BY UPPER BREAKPOINTS
  @if $args == null {
    @media screen {
      @content;
    }
  }
  //  CASE IF DATA IS PASSED WE GENERATE BREAKPOINT FOR PASSED BREAKPOINT
  @else {
    @media screen and (min-width: $args) {
      @content;
    }
  }
}

@mixin clearfix() {
  a::after {
    content: '';
    display: table;
    clear: both;
  }
}

@include breakpoint() {
  padding: 30px 0;

  @include clearfix() {}
}

libsassc

Error: Mixin "clearfix" does not accept a content block.

       Backtrace:
        app/assets/stylesheets/home.scss:59, in mixin `@content`
        app/assets/stylesheets/home.scss:37, in mixin `breakpoint`
        app/assets/stylesheets/home.scss:56
        on line 59 of app/assets/stylesheets/home.scss
>>   @include clearfix() {}
   -----------^

Ruby sass

it renders without issue

In any case this is something minor - I just found it bc. the front-end guy made that small mistake and thus the assets would not compile anymore was curios why that happened.

@chriseppstein
Copy link

Huh. Yeah, I would consider this a bug in ruby sass. A content block is not allowed to that mixin. @nex3 can you confirm?

@chriseppstein chriseppstein added under consideration The Sass team is debating whether to do this and removed needs info Blocked on user response labels Jul 29, 2016
@nex3
Copy link
Contributor

nex3 commented Aug 4, 2016

Yep, looks like a bug to me. Here's a much simpler repro:

@mixin foo() {}
@include foo() {}

It looks like we aren't recognizing the empty content block as something that could trigger the error.

@nex3 nex3 added bug Something isn't working and removed under consideration The Sass team is debating whether to do this labels Aug 4, 2016
maciej-ka added a commit to maciej-ka/sass that referenced this issue Aug 6, 2016
Displays error message 'Mixin "foo" does not accept a content block.'
for this example:

```scss
@mixin foo() {}
@include foo() {}
```

Before, example was rendered without error and only failed if block
inside @include had some statements.

This is fix to:
sass#2106 (comment)
maciej-ka added a commit to maciej-ka/sass that referenced this issue Aug 6, 2016
Displays error message 'Mixin "foo" does not accept a content block.'
for this example:

```scss
@mixin foo() {}
@include foo() {}
```

Before, example was rendered without error and only failed if block
inside ```@include``` had some statements.

This is fix to:
sass#2106
maciej-ka added a commit to maciej-ka/sass-spec that referenced this issue Aug 25, 2016
This will test that lists are compared more strict.
Related to: sass/sass#2106
and: sass/sass#2112
maciej-ka added a commit to maciej-ka/sass-spec that referenced this issue Aug 25, 2016
Tests that an error is raised whenever an empty block is passed to a
mixin.

Related to: sass/sass#2106
and: sass/sass#2112
@nex3 nex3 removed their assignment Dec 12, 2016
maciej-ka added a commit to maciej-ka/sass that referenced this issue Dec 18, 2016
Displays error message 'Mixin "foo" does not accept a content block.'
for this example:

```scss
@mixin foo() {}
@include foo() {}
```

Before, example was rendered without error and only failed if block
inside ```@include``` had some statements.

This is fix to:
sass#2106
maciej-ka added a commit to maciej-ka/sass-spec that referenced this issue Dec 21, 2016
This will test that lists are compared more strict.
Related to: sass/sass#2106
and: sass/sass#2112
maciej-ka added a commit to maciej-ka/sass-spec that referenced this issue Dec 21, 2016
Tests that an error is raised whenever an empty block is passed to a
mixin.

Related to: sass/sass#2106
and: sass/sass#2112
xzyfer pushed a commit to maciej-ka/sass-spec that referenced this issue Jan 2, 2017
This will test that lists are compared more strict.
Related to: sass/sass#2106
and: sass/sass#2112
@nex3
Copy link
Contributor

nex3 commented Apr 6, 2018

I'm moving this issue to the new Ruby Sass repository because it's specific to Ruby Sass's implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
4 participants