Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
`meta.inspect()`, which is to provide full information about the structure of
a Sass value.

* Passing a rest argument (`$arg...`) before a positional or named argument when
calling a function or mixin is now deprecated. This was always outside the
specified syntax, but it was historically treated the same as passing the rest
argument at the end of the argument list whether or not that matched the
visual order of the arguments.

## 1.90.0

* Allow a `@forward`ed module to be loaded with a configuration when that module
Expand Down
7 changes: 6 additions & 1 deletion lib/src/deprecation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum Deprecation {
// DO NOT EDIT. This section was generated from the language repo.
// See tool/grind/generate_deprecations.dart for details.
//
// Checksum: c57ab2eb07ab1df48581b8484ef9bdbad0ddceaa
// Checksum: 1c1efc2604729aea755453fefd1e8f56e100698e

/// Deprecation for passing a string directly to meta.call().
callString('call-string',
Expand Down Expand Up @@ -131,6 +131,11 @@ enum Deprecation {
deprecatedIn: '1.88.0',
description: 'Passing a relative url to compileString().'),

/// Deprecation for a rest parameter before a positional or named parameter.
misplacedRest('misplaced-rest',
deprecatedIn: '1.91.0',
description: 'A rest parameter before a positional or named parameter.'),

// END AUTOGENERATED CODE

/// Used for deprecations coming from user-authored code.
Expand Down
26 changes: 26 additions & 0 deletions lib/src/parse/stylesheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import '../exception.dart';
import '../interpolation_buffer.dart';
import '../util/character.dart';
import '../utils.dart';
import '../util/multi_span.dart';
import '../util/nullable.dart';
import '../value.dart';
import 'parser.dart';
Expand Down Expand Up @@ -1832,6 +1833,7 @@ abstract class StylesheetParser extends Parser {
var named = <String, Expression>{};
Expression? rest;
Expression? keywordRest;
var emittedRestDeprecation = false;
while (_lookingAtExpression()) {
var expression = expressionUntilComma(singleEquals: !mixin);
whitespace(consumeNewlines: true);
Expand All @@ -1842,6 +1844,19 @@ abstract class StylesheetParser extends Parser {
error("Duplicate argument.", expression.span);
}
named[expression.name] = expressionUntilComma(singleEquals: !mixin);

if (rest != null && !emittedRestDeprecation) {
emittedRestDeprecation = true;
warnings.add((
deprecation: Deprecation.misplacedRest,
message: 'Named arguments must come before rest arguments.\n'
'This will be an error in Dart Sass 2.0.0.',
span: MultiSpan(
scanner.spanFromPosition(expression.span.start.offset),
'named argument',
{rest.span: 'rest argument'})
));
}
} else if (scanner.scanChar($dot)) {
scanner.expectChar($dot);
scanner.expectChar($dot);
Expand All @@ -1860,6 +1875,17 @@ abstract class StylesheetParser extends Parser {
);
} else {
positional.add(expression);

if (rest != null && !emittedRestDeprecation) {
emittedRestDeprecation = true;
warnings.add((
deprecation: Deprecation.misplacedRest,
message: 'Positional arguments must come before rest arguments.\n'
'This will be an error in Dart Sass 2.0.0.',
span: MultiSpan(expression.span, 'positional argument',
{rest.span: 'rest argument'})
));
}
}

whitespace(consumeNewlines: true);
Expand Down