GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Silence compiler warnings in dependency callables with --quiet-deps (… · sass/dart-sass@3abcc20

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • CHANGELOG.md
  • lib/src
    • async_import_cache.dart
    • callable
      • user_defined.dart
    • import_cache.dart
    • visitor
      • async_evaluate.dart
      • evaluate.dart
  • pubspec.yaml
  • test/cli
    • shared.dart
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎CHANGELOG.md‎

Copy file name to clipboardExpand all lines: CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.49.10
2+
3+
* Quiet deps mode now silences compiler warnings in mixins and functions that
4+
are defined in dependencies even if they're invoked from application
5+
stylesheets.
6+
17
## 1.49.9
28

39
### Embedded Sass
Collapse file

‎lib/src/async_import_cache.dart‎

Copy file name to clipboardExpand all lines: lib/src/async_import_cache.dart
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ class AsyncImportCache {
127127
var resolvedUrl = baseUrl?.resolveUri(url) ?? url;
128128
var canonicalUrl =
129129
await _canonicalize(baseImporter, resolvedUrl, forImport);
130-
if (canonicalUrl != null) {
131-
return Tuple3(baseImporter, canonicalUrl, resolvedUrl);
132-
}
130+
if (canonicalUrl == null) return null;
131+
return Tuple3(baseImporter, canonicalUrl, resolvedUrl);
133132
});
134133
if (relativeResult != null) return relativeResult;
135134
}
Collapse file

‎lib/src/callable/user_defined.dart‎

Copy file name to clipboardExpand all lines: lib/src/callable/user_defined.dart
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ class UserDefinedCallable<E> implements Callable {
1515
/// The environment in which this callable was declared.
1616
final E environment;
1717

18+
/// Whether this callable was defined in a dependency.
19+
///
20+
/// That is, whether this was (transitively) loaded through a load path or
21+
/// importer rather than relative to the entrypoint.
22+
final bool inDependency;
23+
1824
String get name => declaration.name;
1925

20-
UserDefinedCallable(this.declaration, this.environment);
26+
UserDefinedCallable(this.declaration, this.environment,
27+
{required this.inDependency});
2128
}
Collapse file

‎lib/src/import_cache.dart‎

Copy file name to clipboardExpand all lines: lib/src/import_cache.dart
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// DO NOT EDIT. This file was generated from async_import_cache.dart.
66
// See tool/grind/synchronize.dart for details.
77
//
8-
// Checksum: 3e290e40f4576be99217ddfbd7a76c4d38721af1
8+
// Checksum: cd71f3debc089cd05cd86e2eee32c2f10a05f489
99
//
1010
// ignore_for_file: unused_import
1111

Collapse file

‎lib/src/visitor/async_evaluate.dart‎

Copy file name to clipboardExpand all lines: lib/src/visitor/async_evaluate.dart
+20-6Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ class _EvaluateVisitor
187187
/// The human-readable name of the current stack frame.
188188
var _member = "root stylesheet";
189189

190+
/// The innermost user-defined callable that's being invoked.
191+
UserDefinedCallable<AsyncEnvironment>? _currentCallable;
192+
190193
/// The node for the innermost callable that's being invoked.
191194
///
192195
/// This is used to produce warnings for function calls. It's stored as an
@@ -1415,7 +1418,8 @@ class _EvaluateVisitor
14151418
}
14161419

14171420
Future<Value?> visitFunctionRule(FunctionRule node) async {
1418-
_environment.setFunction(UserDefinedCallable(node, _environment.closure()));
1421+
_environment.setFunction(UserDefinedCallable(node, _environment.closure(),
1422+
inDependency: _inDependency));
14191423
return null;
14201424
}
14211425

@@ -1704,8 +1708,9 @@ class _EvaluateVisitor
17041708
_stackTrace(node.spanWithoutContent));
17051709
}
17061710

1707-
var contentCallable = node.content.andThen(
1708-
(content) => UserDefinedCallable(content, _environment.closure()));
1711+
var contentCallable = node.content.andThen((content) =>
1712+
UserDefinedCallable(content, _environment.closure(),
1713+
inDependency: _inDependency));
17091714
await _runUserDefinedCallable(node.arguments, mixin, nodeWithSpan,
17101715
() async {
17111716
await _environment.withContent(contentCallable, () async {
@@ -1724,7 +1729,8 @@ class _EvaluateVisitor
17241729
}
17251730

17261731
Future<Value?> visitMixinRule(MixinRule node) async {
1727-
_environment.setMixin(UserDefinedCallable(node, _environment.closure()));
1732+
_environment.setMixin(UserDefinedCallable(node, _environment.closure(),
1733+
inDependency: _inDependency));
17281734
return null;
17291735
}
17301736

@@ -2428,7 +2434,9 @@ class _EvaluateVisitor
24282434
var name = callable.name;
24292435
if (name != "@content") name += "()";
24302436

2431-
return await _withStackFrame(name, nodeWithSpan, () {
2437+
var oldCallable = _currentCallable;
2438+
_currentCallable = callable;
2439+
var result = await _withStackFrame(name, nodeWithSpan, () {
24322440
// Add an extra closure() call so that modifications to the environment
24332441
// don't affect the underlying environment closure.
24342442
return _withEnvironment(callable.environment.closure(), () {
@@ -2493,6 +2501,8 @@ class _EvaluateVisitor
24932501
});
24942502
});
24952503
});
2504+
_currentCallable = oldCallable;
2505+
return result;
24962506
}
24972507

24982508
/// Evaluates [arguments] as applied to [callable].
@@ -3287,7 +3297,11 @@ class _EvaluateVisitor
32873297

32883298
/// Emits a warning with the given [message] about the given [span].
32893299
void _warn(String message, FileSpan span, {bool deprecation = false}) {
3290-
if (_quietDeps && _inDependency) return;
3300+
if (_quietDeps &&
3301+
(_inDependency || (_currentCallable?.inDependency ?? false))) {
3302+
return;
3303+
}
3304+
32913305
if (!_warningsEmitted.add(Tuple2(message, span))) return;
32923306
_logger.warn(message,
32933307
span: span, trace: _stackTrace(span), deprecation: deprecation);
Collapse file

‎lib/src/visitor/evaluate.dart‎

Copy file name to clipboardExpand all lines: lib/src/visitor/evaluate.dart
+21-7Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// DO NOT EDIT. This file was generated from async_evaluate.dart.
66
// See tool/grind/synchronize.dart for details.
77
//
8-
// Checksum: d0af88db460da6528bdfeef34eb85baac00f9435
8+
// Checksum: f11bdd289c888e0e0737bc96e63283bc8a332d9a
99
//
1010
// ignore_for_file: unused_import
1111

@@ -195,6 +195,9 @@ class _EvaluateVisitor
195195
/// The human-readable name of the current stack frame.
196196
var _member = "root stylesheet";
197197

198+
/// The innermost user-defined callable that's being invoked.
199+
UserDefinedCallable<Environment>? _currentCallable;
200+
198201
/// The node for the innermost callable that's being invoked.
199202
///
200203
/// This is used to produce warnings for function calls. It's stored as an
@@ -1415,7 +1418,8 @@ class _EvaluateVisitor
14151418
}
14161419

14171420
Value? visitFunctionRule(FunctionRule node) {
1418-
_environment.setFunction(UserDefinedCallable(node, _environment.closure()));
1421+
_environment.setFunction(UserDefinedCallable(node, _environment.closure(),
1422+
inDependency: _inDependency));
14191423
return null;
14201424
}
14211425

@@ -1701,8 +1705,9 @@ class _EvaluateVisitor
17011705
_stackTrace(node.spanWithoutContent));
17021706
}
17031707

1704-
var contentCallable = node.content.andThen(
1705-
(content) => UserDefinedCallable(content, _environment.closure()));
1708+
var contentCallable = node.content.andThen((content) =>
1709+
UserDefinedCallable(content, _environment.closure(),
1710+
inDependency: _inDependency));
17061711
_runUserDefinedCallable(node.arguments, mixin, nodeWithSpan, () {
17071712
_environment.withContent(contentCallable, () {
17081713
_environment.asMixin(() {
@@ -1720,7 +1725,8 @@ class _EvaluateVisitor
17201725
}
17211726

17221727
Value? visitMixinRule(MixinRule node) {
1723-
_environment.setMixin(UserDefinedCallable(node, _environment.closure()));
1728+
_environment.setMixin(UserDefinedCallable(node, _environment.closure(),
1729+
inDependency: _inDependency));
17241730
return null;
17251731
}
17261732

@@ -2414,7 +2420,9 @@ class _EvaluateVisitor
24142420
var name = callable.name;
24152421
if (name != "@content") name += "()";
24162422

2417-
return _withStackFrame(name, nodeWithSpan, () {
2423+
var oldCallable = _currentCallable;
2424+
_currentCallable = callable;
2425+
var result = _withStackFrame(name, nodeWithSpan, () {
24182426
// Add an extra closure() call so that modifications to the environment
24192427
// don't affect the underlying environment closure.
24202428
return _withEnvironment(callable.environment.closure(), () {
@@ -2478,6 +2486,8 @@ class _EvaluateVisitor
24782486
});
24792487
});
24802488
});
2489+
_currentCallable = oldCallable;
2490+
return result;
24812491
}
24822492

24832493
/// Evaluates [arguments] as applied to [callable].
@@ -3257,7 +3267,11 @@ class _EvaluateVisitor
32573267

32583268
/// Emits a warning with the given [message] about the given [span].
32593269
void _warn(String message, FileSpan span, {bool deprecation = false}) {
3260-
if (_quietDeps && _inDependency) return;
3270+
if (_quietDeps &&
3271+
(_inDependency || (_currentCallable?.inDependency ?? false))) {
3272+
return;
3273+
}
3274+
32613275
if (!_warningsEmitted.add(Tuple2(message, span))) return;
32623276
_logger.warn(message,
32633277
span: span, trace: _stackTrace(span), deprecation: deprecation);
Collapse file

‎pubspec.yaml‎

Copy file name to clipboardExpand all lines: pubspec.yaml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.49.9
2+
version: 1.49.10-dev
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

Collapse file

‎test/cli/shared.dart‎

Copy file name to clipboardExpand all lines: test/cli/shared.dart
+126Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,132 @@ void sharedTests(
506506
await sass.shouldExit(0);
507507
});
508508
});
509+
510+
group("in dependency callables", () {
511+
group("(mixin)", () {
512+
test("emits @warn", () async {
513+
await d.file("test.scss", """
514+
@use 'other';
515+
@include other.foo;
516+
""").create();
517+
518+
await d.dir("dir", [
519+
d.file("_other.scss", """
520+
@mixin foo {
521+
@warn heck;
522+
}
523+
""")
524+
]).create();
525+
526+
var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]);
527+
expect(sass.stderr, emitsThrough(contains("heck")));
528+
await sass.shouldExit(0);
529+
});
530+
531+
test("emits @debug", () async {
532+
await d.file("test.scss", """
533+
@use 'other';
534+
@include other.foo;
535+
""").create();
536+
537+
await d.dir("dir", [
538+
d.file("_other.scss", """
539+
@mixin foo {
540+
@debug heck;
541+
}
542+
""")
543+
]).create();
544+
545+
var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]);
546+
expect(sass.stderr, emitsThrough(contains("heck")));
547+
await sass.shouldExit(0);
548+
});
549+
550+
test("doesn't emit runner warnings", () async {
551+
await d.file("test.scss", """
552+
@use 'other';
553+
@include other.foo;
554+
""").create();
555+
556+
await d.dir("dir", [
557+
d.file("_other.scss", """
558+
@mixin foo {
559+
#{blue} {x: y}
560+
}
561+
""")
562+
]).create();
563+
await d.file("test.scss", "@use 'other'").create();
564+
await d.dir("dir", [d.file("_other.scss", "")]).create();
565+
566+
var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]);
567+
expect(sass.stderr, emitsDone);
568+
await sass.shouldExit(0);
569+
});
570+
});
571+
572+
group("(function)", () {
573+
test("emits @warn", () async {
574+
await d.file("test.scss", r"""
575+
@use 'other';
576+
$_: other.foo();
577+
""").create();
578+
579+
await d.dir("dir", [
580+
d.file("_other.scss", """
581+
@function foo() {
582+
@warn heck;
583+
@return null;
584+
}
585+
""")
586+
]).create();
587+
588+
var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]);
589+
expect(sass.stderr, emitsThrough(contains("heck")));
590+
await sass.shouldExit(0);
591+
});
592+
593+
test("emits @debug", () async {
594+
await d.file("test.scss", r"""
595+
@use 'other';
596+
$_: other.foo();
597+
""").create();
598+
599+
await d.dir("dir", [
600+
d.file("_other.scss", """
601+
@function foo() {
602+
@debug heck;
603+
@return null;
604+
}
605+
""")
606+
]).create();
607+
608+
var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]);
609+
expect(sass.stderr, emitsThrough(contains("heck")));
610+
await sass.shouldExit(0);
611+
});
612+
613+
test("doesn't emit runner warnings", () async {
614+
await d.file("test.scss", r"""
615+
@use 'other';
616+
$_: other.foo();
617+
""").create();
618+
619+
await d.dir("dir", [
620+
d.file("_other.scss", """
621+
@function foo() {
622+
@return #{blue};
623+
}
624+
""")
625+
]).create();
626+
await d.file("test.scss", "@use 'other'").create();
627+
await d.dir("dir", [d.file("_other.scss", "")]).create();
628+
629+
var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]);
630+
expect(sass.stderr, emitsDone);
631+
await sass.shouldExit(0);
632+
});
633+
});
634+
});
509635
});
510636

511637
group("with a bunch of deprecation warnings", () {

0 commit comments

Comments
0 (0)
You are visitor 01402809 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.