Skip to content

issue with multiple assignments on same line #228

Open

Description

@lucy

the if statement in

a= c=
b=
if true; then true; fi

gets parsed as a command name:

(program [0, 0] - [3, 0]
  (command [0, 0] - [2, 7]
    (variable_assignment [0, 0] - [0, 2]
      name: (variable_name [0, 0] - [0, 1]))
    (variable_assignment [0, 3] - [0, 5]
      name: (variable_name [0, 3] - [0, 4]))
    (variable_assignment [1, 0] - [1, 2]
      name: (variable_name [1, 0] - [1, 1]))
    name: (command_name [2, 0] - [2, 2]
      (word [2, 0] - [2, 2]))
    argument: (word [2, 3] - [2, 7]))
  (command [2, 9] - [2, 18]
    name: (command_name [2, 9] - [2, 13]
      (word [2, 9] - [2, 13]))
    argument: (word [2, 14] - [2, 18]))
  (command [2, 20] - [2, 22]
    name: (command_name [2, 20] - [2, 22]
      (word [2, 20] - [2, 22]))))

while

a= c= b=
if true; then true; fi

parses as an if_statement:

(program [0, 0] - [2, 0]
  (variable_assignments [0, 0] - [0, 8]
    (variable_assignment [0, 0] - [0, 2]
      name: (variable_name [0, 0] - [0, 1]))
    (variable_assignment [0, 3] - [0, 5]
      name: (variable_name [0, 3] - [0, 4]))
    (variable_assignment [0, 6] - [0, 8]
      name: (variable_name [0, 6] - [0, 7])))
  (if_statement [1, 0] - [1, 22]
    condition: (command [1, 3] - [1, 7]
      name: (command_name [1, 3] - [1, 7]
        (word [1, 3] - [1, 7])))
    (command [1, 14] - [1, 18]
      name: (command_name [1, 14] - [1, 18]
        (word [1, 14] - [1, 18])))))

Activity

  1. amaanq commented on Feb 10, 2024

    @amaanq
    Member

    reserved rules api might be needed for this (not a thing yet)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions