You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bash extractor: a call after elif, then or do is lost when the line before holds only assignments (v=a w="$(f)") #5572
In a function, a branch whose last line holds only assignments, followed by elif, loses the call elif makes:
if [ -z"${1:-}" ];then
v=a w="$(echo b)"elif ok "$1";then
tree-sitter-bash reads v=a w="$(echo b)" and the next line's elif ok "$1" as one command, whose name is the keyword elif.
The call walk takes elif as the callee, so ok gets no calls edge.
The same happens after then, else, do, while and until.
Reproduced on graphifyy 0.9.122 (newest on PyPI), installed with pip, nothing patched, Python 3.12, Ubuntu.
Reproduction
Two files in a new git repo:
# bin/tool#!/usr/bin/env bash
ROOT="$(cd "$(dirname "$0")/.."&& pwd)"."$ROOT/lib/check.sh"main() {
if [ -z"${1:-}" ];then
v=a w="$(echo b)"elif ok "$1";thenecho"$v$w"fi
}
main "$@"
imports_from bin/tool -> lib/check.sh
calls bin/tool main -> lib/check.sh ok
Got
calls bin/tool (script) -> bin/tool main
imports_from bin/tool -> lib/check.sh
Cause and fix
walk_calls takes the command's first child as its name; here that is the keyword.
When the name is one of if then elif else do while until, the call is the first word after it (a ! aside).
We carry this fix as a local patch and will open a PR.
Activity
github-actions commentedon Nov 28, 2026
Thanks for opening this issue, @yashsaxena. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
fix(bash): read the call after a keyword parsed as a command name (#5572