tree-sitter / tree-sitter-css

CSS grammar for Tree-sitter
MIT License
85 stars 34 forks source link

bug: test failure with tree-sitter 0.22.1 #47

Closed MatthewGentoo closed 3 months ago

MatthewGentoo commented 5 months ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

tree-sitter 0.22.1

Describe the bug

The psuedo-element selector test fails on the latest master, with tree-sitter 0.22.1.

  declarations:
    ✓ Function calls
    ✓ Calls where each argument has multiple values
    ✓ Color literals
    ✓ Numbers
    ✓ Binary arithmetic operators
    ✓ Strings
    ✓ URLs
    ✓ Important declarations
    ✓ Declarations without trailing semicolons
    ✓ Comments right after numbers
    ✓ Declarations at the top level
    ✓ Spaces after colons in property declarations
    ✓ No spaces after colons
    ✓ PostCSS
  selectors:
    ✓ Universal selectors
    ✓ Type selectors
    ✓ Class selectors
    ✓ Id selectors
    ✓ Attribute selectors
    ✓ Pseudo-class selectors
    ✗ Pseudo-element selectors
    ✓ Child selectors
    ✓ Descendant selectors
    ✓ Nesting selectors
    ✓ Sibling selectors
    ✓ The :not selector
  statements:
    ✓ Import statements
    ✓ Namespace statements
    ✓ Keyframes statements
    ✓ Media statements
    ✓ Supports statements
    ✓ Charset statements
    ✓ Other at-statements
  stylesheets:
    ✓ Rule sets

1 failure:

correct / expected / unexpected

  1. Pseudo-element selectors:

    (stylesheet
      (rule_set
        (selectors
          (pseudo_element_selector
            (tag_name)
            (tag_name)))
        (block))
      (rule_set
        (selectors
          (descendant_selector
            (descendant_selector
              (descendant_selector
                (descendant_selector
                  (tag_name)
                  (ERROR
                    (attribute_name)
                    (attribute_name)
                    (attribute_name)
                    (attribute_name)
                    (attribute_name)
                    (attribute_name)
                    (attribute_name))
                  (pseudo_element_selector
                    (tag_name)))
                (tag_name))
              (tag_name))
            (ERROR)
            (pseudo_element_selector
              (tag_name)
              (arguments
                (tag_name)))))
            (arguments
              (tag_name))))
        (block)))

Steps To Reproduce/Bad Parse Tree

  1. Ensure tree-sitter 0.22.1 (or later?) is installed.
  2. Do not run npm i in the tree-sitter-css directory as this will install tree-sitter 0.20.8.
  3. Run tree-sitter test

Expected Behavior/Parse Tree

Test pass.

Repro

No response

jeandudey commented 4 months ago

It seems that it is the :: prefix that makes the tests fail:

https://github.com/tree-sitter/tree-sitter-css/blob/02b4ee757654b7d54fe35352fd8e53a8a4385d42/test/corpus/selectors.txt#L104-L106

For example, changing it to:

=========================
slotted pseudo element
=========================

Works.