emacs-tree-sitter / elisp-tree-sitter

Emacs Lisp bindings for tree-sitter

Home Page:https://emacs-tree-sitter.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repetitions and Predicate Problems

avlec opened this issue · comments

Building queries like the following example which is for C++. Where the storage_class_specifier has zero or one (?) OR zero or more (*) matches throws a rust panic. Error: (rust-panic "Any { .. }") Note that one or more (+) works. I have only tested it for this case where there will be either one or none.

(
    (declaration (storage_class_specifier)? @storage) @test
    (.not-eq? @storage "")
)

Same here, trying to capture all the deps and versions in Cargo.toml file using this query:

(document
    (table [
    ;; capture the dependencies key and from simple:
    ;;
    ;; [dependencies]
    ;; $dep = $ver
    ;;
    ;; and capture from inline tables
    ;;
    ;; [dependencies]
    ;; $dep = { version = $ver }
    ((bare_key) @dependencies-key
     (pair (bare_key) @dep
           [
            ((string) @ver)
            (inline_table (pair (bare_key) @ver-key
                                (string) @ver)+)
           ]))
    ;; capture the dependencies key large-like tables
    ;;
    ;; [dependencies.$dep]
    ;; version = $ver
    ((dotted_key (bare_key) @dependencies-key (bare_key) @dep)
     (pair (bare_key) @ver-key
           (string) @ver)+)
    ])
    (.eq? @dependencies-key "dependencies")
    (.eq? @ver-key "version"))

But getting the same error with the last line. May be I'm missing something

In my case, also, logs are refereing to:

thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /Users/runner/.cargo/git/checkouts/tree-sitter-ae9a8b878b09f085/475b822/lib/binding_rust/lib.rs:1833:72