Fix a variable-assignment bug (#1372)

Closes #1250
This commit is contained in:
Natalie Weizenbaum 2021-06-22 15:10:32 -07:00 committed by GitHub
parent 0f68d7a511
commit 5a9dd9161b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 32 deletions

View File

@ -1,3 +1,11 @@
## 1.35.2
* **Potentially breaking bug fix:** Fixed a bug where certain local variable
declarations nested within multiple `@if` statements would incorrectly
override a global variable. It's unlikely that any real stylesheets were
relying on this bug, but if so they can simply add `!global` to the variable
declaration to preserve the old behavior.
## 1.35.1
* Fix a bug where the quiet dependency flag didn't silence warnings in some

View File

@ -740,18 +740,20 @@ class AsyncEnvironment {
/// executes [callback] and returns its result.
Future<T> scope<T>(Future<T> callback(),
{bool semiGlobal = false, bool when = true}) async {
// We have to track semi-globalness even if `!when` so that
//
// div {
// @if ... {
// $x: y;
// }
// }
//
// doesn't assign to the global scope.
semiGlobal = semiGlobal && _inSemiGlobalScope;
var wasInSemiGlobalScope = _inSemiGlobalScope;
_inSemiGlobalScope = semiGlobal;
if (!when) {
// We still have to track semi-globalness so that
//
// div {
// @if ... {
// $x: y;
// }
// }
//
// doesn't assign to the global scope.
var wasInSemiGlobalScope = _inSemiGlobalScope;
_inSemiGlobalScope = semiGlobal;
try {
return await callback();
} finally {
@ -759,10 +761,6 @@ class AsyncEnvironment {
}
}
semiGlobal = semiGlobal && _inSemiGlobalScope;
var wasInSemiGlobalScope = _inSemiGlobalScope;
_inSemiGlobalScope = semiGlobal;
_variables.add({});
_variableNodes.add({});
_functions.add({});

View File

@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_environment.dart.
// See tool/grind/synchronize.dart for details.
//
// Checksum: d5a12dbc383245a91d1e2fee0e2c4aa38939a3d8
// Checksum: 6e5ee671e0a6e5b1d6ac87beb6aeee1e4b155d74
//
// ignore_for_file: unused_import
@ -746,18 +746,20 @@ class Environment {
/// If [when] is false, this doesn't create a new scope and instead just
/// executes [callback] and returns its result.
T scope<T>(T callback(), {bool semiGlobal = false, bool when = true}) {
// We have to track semi-globalness even if `!when` so that
//
// div {
// @if ... {
// $x: y;
// }
// }
//
// doesn't assign to the global scope.
semiGlobal = semiGlobal && _inSemiGlobalScope;
var wasInSemiGlobalScope = _inSemiGlobalScope;
_inSemiGlobalScope = semiGlobal;
if (!when) {
// We still have to track semi-globalness so that
//
// div {
// @if ... {
// $x: y;
// }
// }
//
// doesn't assign to the global scope.
var wasInSemiGlobalScope = _inSemiGlobalScope;
_inSemiGlobalScope = semiGlobal;
try {
return callback();
} finally {
@ -765,10 +767,6 @@ class Environment {
}
}
semiGlobal = semiGlobal && _inSemiGlobalScope;
var wasInSemiGlobalScope = _inSemiGlobalScope;
_inSemiGlobalScope = semiGlobal;
_variables.add({});
_variableNodes.add({});
_functions.add({});

View File

@ -1,5 +1,5 @@
name: sass
version: 1.35.1
version: 1.35.2-dev
description: A Sass implementation in Dart.
author: Sass Team
homepage: https://github.com/sass/dart-sass