Skip to content

Warning emitted for rule that contains a seq with a single argument #62

@sogaiu

Description

@sogaiu

Since commit tree-sitter/tree-sitter@252e2a4 of the tree-sitter cli, the generate subcommand gives a warning for our grammar (at least at f4236d4):

Warning: rule char_lit is just a `seq` or `choice` rule with a single element. This is unnecessary.

It takes a bit of digging, but the culprit is here [1]:

const OCTAL_CHAR =
      seq("o",
          choice(seq(DIGIT, DIGIT, DIGIT),
                 seq(DIGIT, DIGIT),
                 seq(DIGIT)));

The last seq is seq(DIGIT), which does indeed have a single argument.

I don't know if this is a serious issue, but perhaps it makes sense to remove the seq there.


[1] Thanks to clason and amaanq for getting to the bottom of this. Some more background can be found here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions