Skip to content
This repository was archived by the owner on Feb 23, 2022. It is now read-only.
This repository was archived by the owner on Feb 23, 2022. It is now read-only.

Parsing error with css calc and negative number #136

@blasss

Description

@blasss

The parsing of calc() functions does not seem to recognize negative numbers as part of an expression. The following expression yields an parsing error:
margin-left: calc(var(--size-grid-marker-column-resize) / -2);

com.google.common.css.compiler.ast.GssParserException: Parse error in xxx.css at line 170 column 63:
     margin-left: calc(var(--size-grid-marker-column-resize) / -2);
                                                               ^
Caused by: com.google.common.css.compiler.ast.ParseException: Encountered " "-" "- "" at line 170, column 63.
 Was expecting one of:
     <S> ...
     <NUMBER> ...

According to https://drafts.csswg.org/css-values-3/#calc-notation this is a perfectly valid expression.
As a workaround the expression can be converted to the following form, which is being parsed correctly:
margin-left: calc(0 - (var(--size-grid-marker-column-resize) / 2));

As the outlined expression is valid according to the specification it should be accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions