Emit a proper parse error for = with no RHS in a function (#1071)

Closes #1050
This commit is contained in:
Natalie Weizenbaum 2020-10-27 15:47:48 -07:00 committed by GitHub
parent 26ed30bc54
commit 197c6dbbde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 16 deletions

View File

@ -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.

View File

@ -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
@ -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);
@ -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:
@ -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);
@ -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,

View File

@ -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