Skip to content

Commit

Permalink
Fix --quiet-deps for @content blocks (#2474)
Browse files Browse the repository at this point in the history
Closes #2418
  • Loading branch information
nex3 authored Jan 4, 2025
1 parent 777708c commit 3d3e925
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 19 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 1.83.1-dev
## 1.83.1

* Fix a bug where `--quiet-deps` would get deactivated for `@content` blocks,
even when those blocks were entirely contained within dependencies.

* Include deprecation IDs in deprecation warnings to make it easier to determine
what to pass to `--silence-deprecation` or `--fatal-deprecation`.
Expand Down
11 changes: 5 additions & 6 deletions lib/src/visitor/async_evaluate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1211,8 +1211,7 @@ final class _EvaluateVisitor
if (siblings.last != _parent &&
// Reproduce this condition from [_warn] so that we don't add anything to
// [interleavedRules] for declarations in dependencies.
!(_quietDeps &&
(_inDependency || (_currentCallable?.inDependency ?? false)))) {
!(_quietDeps && _inDependency)) {
loop:
for (var sibling in siblings.skip(siblings.indexOf(_parent) + 1)) {
switch (sibling) {
Expand Down Expand Up @@ -2946,7 +2945,9 @@ final class _EvaluateVisitor
if (name != "@content") name += "()";

var oldCallable = _currentCallable;
var oldInDependency = _inDependency;
_currentCallable = callable;
_inDependency = callable.inDependency;
var result = await _withStackFrame(name, nodeWithSpan, () {
// Add an extra closure() call so that modifications to the environment
// don't affect the underlying environment closure.
Expand Down Expand Up @@ -3014,6 +3015,7 @@ final class _EvaluateVisitor
});
});
_currentCallable = oldCallable;
_inDependency = oldInDependency;
return result;
}

Expand Down Expand Up @@ -3873,10 +3875,7 @@ final class _EvaluateVisitor

/// Emits a warning with the given [message] about the given [span].
void _warn(String message, FileSpan span, [Deprecation? deprecation]) {
if (_quietDeps &&
(_inDependency || (_currentCallable?.inDependency ?? false))) {
return;
}
if (_quietDeps && _inDependency) return;

if (!_warningsEmitted.add((message, span))) return;
var trace = _stackTrace(span);
Expand Down
13 changes: 6 additions & 7 deletions lib/src/visitor/evaluate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_evaluate.dart.
// See tool/grind/synchronize.dart for details.
//
// Checksum: e47d81d6a53ba17bf1f6bf37e431c47fc82195e5
// Checksum: 548e54482bead470a6c7931a9d3e098da8b600d6
//
// ignore_for_file: unused_import

Expand Down Expand Up @@ -1211,8 +1211,7 @@ final class _EvaluateVisitor
if (siblings.last != _parent &&
// Reproduce this condition from [_warn] so that we don't add anything to
// [interleavedRules] for declarations in dependencies.
!(_quietDeps &&
(_inDependency || (_currentCallable?.inDependency ?? false)))) {
!(_quietDeps && _inDependency)) {
loop:
for (var sibling in siblings.skip(siblings.indexOf(_parent) + 1)) {
switch (sibling) {
Expand Down Expand Up @@ -2924,7 +2923,9 @@ final class _EvaluateVisitor
if (name != "@content") name += "()";

var oldCallable = _currentCallable;
var oldInDependency = _inDependency;
_currentCallable = callable;
_inDependency = callable.inDependency;
var result = _withStackFrame(name, nodeWithSpan, () {
// Add an extra closure() call so that modifications to the environment
// don't affect the underlying environment closure.
Expand Down Expand Up @@ -2991,6 +2992,7 @@ final class _EvaluateVisitor
});
});
_currentCallable = oldCallable;
_inDependency = oldInDependency;
return result;
}

Expand Down Expand Up @@ -3837,10 +3839,7 @@ final class _EvaluateVisitor

/// Emits a warning with the given [message] about the given [span].
void _warn(String message, FileSpan span, [Deprecation? deprecation]) {
if (_quietDeps &&
(_inDependency || (_currentCallable?.inDependency ?? false))) {
return;
}
if (_quietDeps && _inDependency) return;

if (!_warningsEmitted.add((message, span))) return;
var trace = _stackTrace(span);
Expand Down
2 changes: 1 addition & 1 deletion pkg/sass-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.4.9-dev
## 0.4.9

* No user-visible changes.

Expand Down
2 changes: 1 addition & 1 deletion pkg/sass-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sass-parser",
"version": "0.4.9-dev",
"version": "0.4.9",
"description": "A PostCSS-compatible wrapper of the official Sass parser",
"repository": "sass/sass",
"author": "Google Inc.",
Expand Down
2 changes: 1 addition & 1 deletion pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 15.0.1-dev
## 15.0.1

* No user-visible changes.

Expand Down
2 changes: 1 addition & 1 deletion pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the
# visitor interface(s).
version: 15.0.1-dev
version: 15.0.1
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.83.1-dev
version: 1.83.1
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down
23 changes: 23 additions & 0 deletions test/cli/shared.dart
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,29 @@ void sharedTests(
expect(sass.stderr, emitsDone);
await sass.shouldExit(0);
});

// Regression test for sass/dart-sass#2418
test("doesn't emit runner warnings in content blocks from local @include",
() async {
await d.file("test.scss", """
@use 'other';
@include other.foo;
""").create();
await d.dir("dir", [
d.file("_other.scss", """
@mixin bar {@content}
@mixin foo {
@include bar {
#{blue} {x: y}
}
}
""")
]).create();

var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]);
expect(sass.stderr, emitsDone);
await sass.shouldExit(0);
});
});

group("silences warnings through @import", () {
Expand Down

0 comments on commit 3d3e925

Please sign in to comment.