-
Notifications
You must be signed in to change notification settings - Fork 462
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
Variables first declared in control flow rules should not be accessible in outer scopes #1746
Comments
Got some results (aka more problems) from a debug session. The following sample should show the problematic behavior (certain scopes seem the behave slightly different): $continue: true;
$while_global1: initial;
$while_global2: initial;
$other_global1: initial;
$other_global2: initial;
// bleads into global
@while $continue {
$while_global1: assigned;
$while_global2: assigned !global;
$continue: false;
}
// does not blead into global
foobar {
$other_global1: assigned;
$other_global2: assigned !global;
}
// different results for global
globals {
while1: $while_global1;
while2: $while_global2;
other1: $other_global1;
other2: $other_global2;
} Result by ruby sass 3.4.19 globals {
while1: assigned;
while2: assigned;
other1: initial;
other2: assigned; } I guess we need a flag on Here another currently failing spec test which shows a related problem: $var: 7;
.selector {
$var: 13;
var: $var;
.inner {
$foo: "dummy";
$var: $var + 3;
}
foo: variable-exists(foo);
var: $var;
}
.other-selector {
content: $var;
} Dev Info: Need flag on env to check in set_lexical. Push a new env to env_stack in ruleset expanding. |
Spec added sass/sass-spec#625 |
Variables assigned in block scopes should not be accessible outside of the scope, unless they have been previously assigned in an outer scope (or the outer scope is global and the
!global
flag is specified).Libsass gets these semantics correct for style,
@at-root
,@media
, and other CSS @-rules, as well as mixins but not for control flow rules (@if
,@while
,@for
, and@each
). Notice in the tests below that the_local
variables being first declared within these rule types are leaking outside.It is also notable that assignments that happen in non-control-flow rules do not overwrite variables that have been previously assigned in an outer scope. These assignments are denoted by variables named
_global
in the tests. Libsass gets this behavior correct, but I have included tests anyway to help prevent a regression.Input:
Ruby SASS Output:
Libsass Output (3.3.2):
The text was updated successfully, but these errors were encountered: