Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

* Don't crash when writing `Infinity` in JS mode.

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

## 1.26.10

* Fixes a bug where two adjacent combinators could cause an error.
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 @@ -1629,8 +1629,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 @@ -1707,7 +1705,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 @@ -1739,12 +1739,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 @@ -1783,9 +1777,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 @@ -2003,9 +1995,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