Fix and refactor delayed evaluation flag #2059
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2042, #2034 and #2057 (Spec tests sass/sass-spec#856).
This is pretty much a complete rewrite of how we handle delayed values:
Issue #2042 was never fully working, but its behavior was changed with #1986 from undelayed to delayed. From my experience libsass struggled to emulate these behaviors from the beginning. First I figured out why #2042 was never working. It turns out that we have to only set delayed on certain parsed ast nodes. And whoever calls parse_list must tell it if values on the first level must be delayed (//CC @xzyfer). This is the case for declarations and argument lists (and others), but not for nested lists (with exceptions).
Once implemented pretty much all other stuff related to delayed values broke. So I set out to fix them one by one, and most were easy. The trickiest one revealed itself in the following sass:
This compiles to (in compressed ❗ mode):
It shows that undelaying colors vs divisions are really two different things. Because in the sample above the color got undelayed, while the division did not. Another key code in the PR is that binary expression never get delayed when they contain nested binary expressions. With this logic in place I was able to remove most of the complicated code regarding delayed value handling.