Skip to content

Commit

Permalink
Emit a proper parse error for = with no RHS in a function (#1071)
Browse files Browse the repository at this point in the history
Closes #1050
  • Loading branch information
nex3 committed Oct 27, 2020
1 parent 26ed30b commit 197c6db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.27.1

* Emit a proper parse error for a `=` with no right-hand side in a function.

## 1.27.0

* Adds an overload to `map.merge()` that supports merging a nested map.
Expand Down
20 changes: 5 additions & 15 deletions lib/src/parse/stylesheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1640,8 +1640,6 @@ relase. For details, see http://bit.ly/moz-document.

List<Expression> commaExpressions;

Expression singleEqualsOperand;

List<Expression> spaceExpressions;

// Operators whose right-hand operands are not fully parsed yet, in order of
Expand Down Expand Up @@ -1718,7 +1716,9 @@ relase. For details, see http://bit.ly/moz-document.
}

void addOperator(BinaryOperator operator) {
if (plainCss && operator != BinaryOperator.dividedBy) {
if (plainCss &&
operator != BinaryOperator.dividedBy &&
operator != BinaryOperator.singleEquals) {
scanner.error("Operators aren't allowed in plain CSS.",
position: scanner.position - operator.operator.length,
length: operator.operator.length);
Expand Down Expand Up @@ -1750,12 +1750,6 @@ relase. For details, see http://bit.ly/moz-document.
ListExpression(spaceExpressions, ListSeparator.space);
spaceExpressions = null;
}

if (singleEqualsOperand != null) {
singleExpression = BinaryOperationExpression(
BinaryOperator.singleEquals, singleEqualsOperand, singleExpression);
singleEqualsOperand = null;
}
}

loop:
Expand Down Expand Up @@ -1794,9 +1788,7 @@ relase. For details, see http://bit.ly/moz-document.
case $equal:
scanner.readChar();
if (singleEquals && scanner.peekChar() != $equal) {
resolveSpaceExpressions();
singleEqualsOperand = singleExpression;
singleExpression = null;
addOperator(BinaryOperator.singleEquals);
} else {
scanner.expectChar($equal);
addOperator(BinaryOperator.equals);
Expand Down Expand Up @@ -2014,9 +2006,7 @@ relase. For details, see http://bit.ly/moz-document.
return ListExpression(commaExpressions, ListSeparator.comma,
brackets: bracketList,
span: bracketList ? scanner.spanFrom(beforeBracket) : null);
} else if (bracketList &&
spaceExpressions != null &&
singleEqualsOperand == null) {
} else if (bracketList && spaceExpressions != null) {
resolveOperations();
return ListExpression(
spaceExpressions..add(singleExpression), ListSeparator.space,
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.27.0
version: 1.27.1-dev
description: A Sass implementation in Dart.
author: Sass Team
homepage: https://github.com/sass/dart-sass
Expand Down

0 comments on commit 197c6db

Please sign in to comment.