Skip to content

falsely reported syntax error for negated conditional assignment statements #135

Closed
@spikegrobstein

Description

@spikegrobstein

I'm getting the message Syntax error: expected "word" somewhere in the file when I have statements like if ! myvar="$( some_func )"; then

A minimal, complete example:

#! /usr/bin/env bash

bar() {
  echo "bar"
  return 1
}

foo=''

if ! foo="$(bar)"; then # <-- Syntax error: expected "word" somewhere in the file
  echo "ok."
fi

If I change it to just if foo="$( bar )"; then, then it doesn't bark. It's the ! that makes it angry.

this is valid bash and executes without issue. This also didn't happen in an older version of bash-language-server. I upgraded the other day, but I'm not sure what the old version I had running was. I use this structure in my code all the time so it's kinda annoying to constantly see this syntax error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    grammar 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