Skip to content

Incorrect parsing of RHS of binary expression when it looks like a flag #150

@lincheney

Description

@lincheney

The following
[ a = -d ]
is incorrectly parsed as

program [0, 0] - [1, 0]
  test_command [0, 0] - [0, 10]
    binary_expression [0, 2] - [0, 10]
      left: word [0, 2] - [0, 3]
      right: unary_expression [0, 6] - [0, 10]
        test_operator [0, 6] - [0, 8]
        word [0, 9] - [0, 10]
    MISSING ] [0, 10] - [0, 10]

Notably the -d in this context is a string literal, but is being treated as the the test_operator in a unary_expression (which also swallows the ] as the unary operand, resulting in the incorrect MISSING ] at the end)

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