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

Error when declarations are printed without ruleset #2062

Merged
merged 2 commits into from
May 2, 2016

Conversation

xzyfer
Copy link
Contributor

@xzyfer xzyfer commented May 1, 2016

This is introduces a vastly reduced CheckNesting visitor from Ruby
Sass as discussed in #2061. Doing this properly will require some
small changes to the parser, and probably eval, which currently try
to do some nesting checking of their own.

This is just first step to properly introducing the proper nesting
checking.

Spec sass/sass-spec#857
Closes #2061
Fixes #1732

@xzyfer xzyfer self-assigned this May 1, 2016
@xzyfer xzyfer added this to the 3.3.7 milestone May 1, 2016
@xzyfer xzyfer force-pushed the fix/issue-1732 branch from 7d6dc44 to 0adb508 Compare May 1, 2016 11:46
@xzyfer xzyfer changed the title Error when declarations are printed without ruleset [WIP] Error when declarations are printed without ruleset May 1, 2016

Statement* CheckNesting::operator()(Declaration* d)
{
if (block_stack.size() < 2) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check still needs work and the test case will need to be updated.

@coveralls
Copy link

coveralls commented May 1, 2016

Coverage Status

Coverage increased (+0.05%) to 79.13% when pulling 0adb508 on xzyfer:fix/issue-1732 into c95478c on sass:master.


Statement* CheckNesting::operator()(Block* b)
{
Block* bb = SASS_MEMORY_NEW(ctx.mem, Block, b->pstate(), b->length(), b->is_root());
Copy link
Contributor

@mgreter mgreter May 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really necessary to make another copy? I figure this should not be needed since we do not really alter anything here? Creating too many clones is the main reason why libsass is slower than it could be (I already removed some cloning in eval some time ago, which lead to the big performance gain). The other reason we are slower than needed is that we visit too many visitors, but I guess there is not much too avoid that and it should not have a big impact ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we don't need the copy. I slimmed this down a lot, fixed the check, and beefed out the spec. This visitor should never mutate the nodes.

Copy link
Contributor

@mgreter mgreter May 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO if it should never mutate than the append_block is also superflous. Doesn't it always replace the children with itself anyway under that condition? Otherwise good work!

Probably something like that should do it:

Statement* CheckNesting::operator()(Block* b)
{
  for (auto child : b->elements()) {
    child->perform(this);
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep I've also removed that locally. Just pushed my latest. Tracking down an error mismatch atm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mgreter
Copy link
Contributor

mgreter commented May 1, 2016

Other than my comments, LGTM!

@xzyfer xzyfer force-pushed the fix/issue-1732 branch 2 times, most recently from a396a3f to 2e7810d Compare May 2, 2016 10:22
@xzyfer
Copy link
Contributor Author

xzyfer commented May 2, 2016

Beefed out the specs in sass/sass-spec#857

This is introduces a vastly reduced `CheckNesting` visitor from Ruby
Sass as discussed in sass#2061. Doing this properly will require some
small changes to the parser, and probably eval, which currently try
to do some nesting checking of their own.

This is just first step to properly introducing the proper nesting
checking.

Closes sass#2061
Fixes sass#1732
@xzyfer xzyfer force-pushed the fix/issue-1732 branch from 2e7810d to 6d6fab6 Compare May 2, 2016 10:23
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 79.415% when pulling a396a3f on xzyfer:fix/issue-1732 into 52628d0 on sass:master.

@xzyfer xzyfer changed the title [WIP] Error when declarations are printed without ruleset Error when declarations are printed without ruleset May 2, 2016
@coveralls
Copy link

coveralls commented May 2, 2016

Coverage Status

Coverage increased (+0.2%) to 79.248% when pulling 6d6fab6 on xzyfer:fix/issue-1732 into 52628d0 on sass:master.

@coveralls
Copy link

coveralls commented May 2, 2016

Coverage Status

Coverage increased (+0.2%) to 79.239% when pulling c75f24d on xzyfer:fix/issue-1732 into 52628d0 on sass:master.

@xzyfer xzyfer merged commit d8fb898 into sass:master May 2, 2016
@xzyfer xzyfer deleted the fix/issue-1732 branch May 2, 2016 11:54
@xzyfer xzyfer modified the milestones: 3.3.7, 3.4 Oct 20, 2016
xzyfer added a commit to xzyfer/libsass that referenced this pull request Dec 29, 2016
The check nesting visitor is responsible for AST validation. This
was left over from sass#2062. Also fixed a bug that caused the function
child node validation to be skipped.
xzyfer added a commit to xzyfer/libsass that referenced this pull request Dec 29, 2016
The check nesting visitor is responsible for AST validation. This
was left over from sass#2062.
xzyfer added a commit that referenced this pull request Dec 29, 2016
The check nesting visitor is responsible for AST validation. This
was left over from #2062. Also fixed a bug that caused the function
child node validation to be skipped.
xzyfer added a commit that referenced this pull request Dec 29, 2016
The check nesting visitor is responsible for AST validation. This
was left over from #2062.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants