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

Missing MISSING when the terminal is a hidden rule #1043

Closed
alemuller opened this issue Apr 4, 2021 · 3 comments
Closed

Missing MISSING when the terminal is a hidden rule #1043

alemuller opened this issue Apr 4, 2021 · 3 comments

Comments

@alemuller
Copy link
Contributor

alemuller commented Apr 4, 2021

Code to reproduce:

module.exports = grammar({
    name: 'test',
    extras: $ => [ /\s+/ ],
    rules: {

        top: $ => repeat($.foo),

        foo: $ => seq(
            alias('(',$.open),
            $.symbol,
            alias(')',$.close)
        ),

        symbol: $ => $._word,

        // changing the rule name from `_word` to `word` it works as expected
        _word: $ => 'x',
    }
});

The aliases are not needed but they helped me to pinpoint the issue.

Test file:

()

Command:

$ tree-sitter --version
tree-sitter 0.19.4 (76862e281b3aa5d93b471bfdf903527fec4f9b29)
$ tree-sitter parse foo.test

Actual:

(top [0, 0] - [1, 0]
  (foo [0, 0] - [0, 2]
    (open [0, 0] - [0, 1])
    (symbol [0, 1] - [0, 1])
    (close [0, 1] - [0, 2])))

Expected:

(top [0, 0] - [1, 0]
  (foo [0, 0] - [0, 2]
    (open [0, 0] - [0, 1])
    (symbol [0, 1] - [0, 1])
    (close [0, 1] - [0, 2])))
test.test	0 ms	(MISSING symbol [0, 1] - [0, 1]

NOTE: Replacing _word with word in the grammar tree-sitter parse produces the correct output.

@ahlinc
Copy link
Contributor

ahlinc commented Sep 14, 2021

In tests it's present:

================================================================================
Missing MISSING
================================================================================

()

--------------------------------------------------------------------------------

(top
  (foo
    (open)
    (symbol
      (MISSING _word))
    (close)))

So this is a bug in CLI representation of S-expressions.

@ahlinc
Copy link
Contributor

ahlinc commented Sep 14, 2021

Similar to #865

@DavisVaughan
Copy link
Contributor

DavisVaughan commented Apr 2, 2024

I think this issue goes a little deeper than just the CLI representation. I have a similar situation but for me ts_node_is_missing() reports false on, for example, the symbol node from above, making it impossible to actually detect that this is a missing node.

It's doubly confusing because ts_node_has_error() will report true when called on the root node, which is correct, but then you can't find the MISSING node causing the error!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants