GeezerVison is showing github.com — Silence compiler warnings in dependency callables with --quiet-deps (… · sass/dart-sass@3abcc20
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file 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 number | Diff line number | Diff line change |
|---|
| | 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 | + | 1 | 7 | ## 1.49.9 | 2 | 8 |
| 3 | 9 | ### Embedded Sass | |
Collapse file Copy file name to clipboardExpand all lines: lib/src/async_import_cache.dart +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -127,9 +127,8 @@ class AsyncImportCache { | 127 | 127 | var resolvedUrl = baseUrl?.resolveUri(url) ?? url; | 128 | 128 | var canonicalUrl = | 129 | 129 | 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); | 133 | 132 | }); | 134 | 133 | if (relativeResult != null) return relativeResult; | 135 | 134 | } | |
Collapse file Copy file name to clipboardExpand all lines: lib/src/callable/user_defined.dart +8-1Lines changed: 8 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,14 @@ class UserDefinedCallable<E> implements Callable { | 15 | 15 | /// The environment in which this callable was declared. | 16 | 16 | final E environment; | 17 | 17 |
| | 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 | + | 18 | 24 | String get name => declaration.name; | 19 | 25 |
| 20 | | - UserDefinedCallable(this.declaration, this.environment); | | 26 | + UserDefinedCallable(this.declaration, this.environment, | | 27 | + {required this.inDependency}); | 21 | 28 | } |
Collapse file Copy file name to clipboardExpand all lines: lib/src/import_cache.dart +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 | // DO NOT EDIT. This file was generated from async_import_cache.dart. | 6 | 6 | // See tool/grind/synchronize.dart for details. | 7 | 7 | // | 8 | | -// Checksum: 3e290e40f4576be99217ddfbd7a76c4d38721af1 | | 8 | +// Checksum: cd71f3debc089cd05cd86e2eee32c2f10a05f489 | 9 | 9 | // | 10 | 10 | // ignore_for_file: unused_import | 11 | 11 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/src/visitor/async_evaluate.dart +20-6Lines changed: 20 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -187,6 +187,9 @@ class _EvaluateVisitor | 187 | 187 | /// The human-readable name of the current stack frame. | 188 | 188 | var _member = "root stylesheet"; | 189 | 189 |
| | 190 | + /// The innermost user-defined callable that's being invoked. | | 191 | + UserDefinedCallable<AsyncEnvironment>? _currentCallable; | | 192 | + | 190 | 193 | /// The node for the innermost callable that's being invoked. | 191 | 194 | /// | 192 | 195 | /// This is used to produce warnings for function calls. It's stored as an | @@ -1415,7 +1418,8 @@ class _EvaluateVisitor | 1415 | 1418 | } | 1416 | 1419 |
| 1417 | 1420 | Future<Value?> visitFunctionRule(FunctionRule node) async { | 1418 | | - _environment.setFunction(UserDefinedCallable(node, _environment.closure())); | | 1421 | + _environment.setFunction(UserDefinedCallable(node, _environment.closure(), | | 1422 | + inDependency: _inDependency)); | 1419 | 1423 | return null; | 1420 | 1424 | } | 1421 | 1425 |
| @@ -1704,8 +1708,9 @@ class _EvaluateVisitor | 1704 | 1708 | _stackTrace(node.spanWithoutContent)); | 1705 | 1709 | } | 1706 | 1710 |
| 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)); | 1709 | 1714 | await _runUserDefinedCallable(node.arguments, mixin, nodeWithSpan, | 1710 | 1715 | () async { | 1711 | 1716 | await _environment.withContent(contentCallable, () async { | @@ -1724,7 +1729,8 @@ class _EvaluateVisitor | 1724 | 1729 | } | 1725 | 1730 |
| 1726 | 1731 | Future<Value?> visitMixinRule(MixinRule node) async { | 1727 | | - _environment.setMixin(UserDefinedCallable(node, _environment.closure())); | | 1732 | + _environment.setMixin(UserDefinedCallable(node, _environment.closure(), | | 1733 | + inDependency: _inDependency)); | 1728 | 1734 | return null; | 1729 | 1735 | } | 1730 | 1736 |
| @@ -2428,7 +2434,9 @@ class _EvaluateVisitor | 2428 | 2434 | var name = callable.name; | 2429 | 2435 | if (name != "@content") name += "()"; | 2430 | 2436 |
| 2431 | | - return await _withStackFrame(name, nodeWithSpan, () { | | 2437 | + var oldCallable = _currentCallable; | | 2438 | + _currentCallable = callable; | | 2439 | + var result = await _withStackFrame(name, nodeWithSpan, () { | 2432 | 2440 | // Add an extra closure() call so that modifications to the environment | 2433 | 2441 | // don't affect the underlying environment closure. | 2434 | 2442 | return _withEnvironment(callable.environment.closure(), () { | @@ -2493,6 +2501,8 @@ class _EvaluateVisitor | 2493 | 2501 | }); | 2494 | 2502 | }); | 2495 | 2503 | }); | | 2504 | + _currentCallable = oldCallable; | | 2505 | + return result; | 2496 | 2506 | } | 2497 | 2507 |
| 2498 | 2508 | /// Evaluates [arguments] as applied to [callable]. | @@ -3287,7 +3297,11 @@ class _EvaluateVisitor | 3287 | 3297 |
| 3288 | 3298 | /// Emits a warning with the given [message] about the given [span]. | 3289 | 3299 | 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 | + | 3291 | 3305 | if (!_warningsEmitted.add(Tuple2(message, span))) return; | 3292 | 3306 | _logger.warn(message, | 3293 | 3307 | span: span, trace: _stackTrace(span), deprecation: deprecation); | |
Collapse file Copy file name to clipboardExpand all lines: lib/src/visitor/evaluate.dart +21-7Lines changed: 21 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 | // DO NOT EDIT. This file was generated from async_evaluate.dart. | 6 | 6 | // See tool/grind/synchronize.dart for details. | 7 | 7 | // | 8 | | -// Checksum: d0af88db460da6528bdfeef34eb85baac00f9435 | | 8 | +// Checksum: f11bdd289c888e0e0737bc96e63283bc8a332d9a | 9 | 9 | // | 10 | 10 | // ignore_for_file: unused_import | 11 | 11 |
| @@ -195,6 +195,9 @@ class _EvaluateVisitor | 195 | 195 | /// The human-readable name of the current stack frame. | 196 | 196 | var _member = "root stylesheet"; | 197 | 197 |
| | 198 | + /// The innermost user-defined callable that's being invoked. | | 199 | + UserDefinedCallable<Environment>? _currentCallable; | | 200 | + | 198 | 201 | /// The node for the innermost callable that's being invoked. | 199 | 202 | /// | 200 | 203 | /// This is used to produce warnings for function calls. It's stored as an | @@ -1415,7 +1418,8 @@ class _EvaluateVisitor | 1415 | 1418 | } | 1416 | 1419 |
| 1417 | 1420 | Value? visitFunctionRule(FunctionRule node) { | 1418 | | - _environment.setFunction(UserDefinedCallable(node, _environment.closure())); | | 1421 | + _environment.setFunction(UserDefinedCallable(node, _environment.closure(), | | 1422 | + inDependency: _inDependency)); | 1419 | 1423 | return null; | 1420 | 1424 | } | 1421 | 1425 |
| @@ -1701,8 +1705,9 @@ class _EvaluateVisitor | 1701 | 1705 | _stackTrace(node.spanWithoutContent)); | 1702 | 1706 | } | 1703 | 1707 |
| 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)); | 1706 | 1711 | _runUserDefinedCallable(node.arguments, mixin, nodeWithSpan, () { | 1707 | 1712 | _environment.withContent(contentCallable, () { | 1708 | 1713 | _environment.asMixin(() { | @@ -1720,7 +1725,8 @@ class _EvaluateVisitor | 1720 | 1725 | } | 1721 | 1726 |
| 1722 | 1727 | Value? visitMixinRule(MixinRule node) { | 1723 | | - _environment.setMixin(UserDefinedCallable(node, _environment.closure())); | | 1728 | + _environment.setMixin(UserDefinedCallable(node, _environment.closure(), | | 1729 | + inDependency: _inDependency)); | 1724 | 1730 | return null; | 1725 | 1731 | } | 1726 | 1732 |
| @@ -2414,7 +2420,9 @@ class _EvaluateVisitor | 2414 | 2420 | var name = callable.name; | 2415 | 2421 | if (name != "@content") name += "()"; | 2416 | 2422 |
| 2417 | | - return _withStackFrame(name, nodeWithSpan, () { | | 2423 | + var oldCallable = _currentCallable; | | 2424 | + _currentCallable = callable; | | 2425 | + var result = _withStackFrame(name, nodeWithSpan, () { | 2418 | 2426 | // Add an extra closure() call so that modifications to the environment | 2419 | 2427 | // don't affect the underlying environment closure. | 2420 | 2428 | return _withEnvironment(callable.environment.closure(), () { | @@ -2478,6 +2486,8 @@ class _EvaluateVisitor | 2478 | 2486 | }); | 2479 | 2487 | }); | 2480 | 2488 | }); | | 2489 | + _currentCallable = oldCallable; | | 2490 | + return result; | 2481 | 2491 | } | 2482 | 2492 |
| 2483 | 2493 | /// Evaluates [arguments] as applied to [callable]. | @@ -3257,7 +3267,11 @@ class _EvaluateVisitor | 3257 | 3267 |
| 3258 | 3268 | /// Emits a warning with the given [message] about the given [span]. | 3259 | 3269 | 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 | + | 3261 | 3275 | if (!_warningsEmitted.add(Tuple2(message, span))) return; | 3262 | 3276 | _logger.warn(message, | 3263 | 3277 | span: span, trace: _stackTrace(span), deprecation: deprecation); | |
Collapse file Copy file name to clipboardExpand all lines: pubspec.yaml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | name: sass | 2 | | -version: 1.49.9 | | 2 | +version: 1.49.10-dev | 3 | 3 | description: A Sass implementation in Dart. | 4 | 4 | homepage: https://github.com/sass/dart-sass | 5 | 5 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/cli/shared.dart +126Lines changed: 126 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -506,6 +506,132 @@ void sharedTests( | 506 | 506 | await sass.shouldExit(0); | 507 | 507 | }); | 508 | 508 | }); | | 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 | + }); | 509 | 635 | }); | 510 | 636 |
| 511 | 637 | group("with a bunch of deprecation warnings", () { | |
|