Skip to content

Syntax error false positive for array indexes that are arithmetic expressions with spaces #706

Closed
@akwala

Description

@akwala

Code editor

Codium (VS Code)

Platform

Linux/Ubuntu

Version

4.4.0

What steps will reproduce the bug?

Code example:

value=array[i - 2]

This is flagged as a syntax error:

Syntax error: "]" missing

Changing the code as follows gets rid of the error:

value=array[i-2]

With this modified code, AFAICT, shell-format (shfmt) inserts the spaces around the minus. It is not a syntax error to have those spaces.

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

This should not be flagged as a syntax error.

What do you see instead?

Syntax error: "]" missing

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggrammar bugIssues related to the bash grammar

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions