Skip to content

Commit 55d279f

Browse files
committed
syntax: simplify zsh logic on left parentheses
This does slightly alter two error messages, but not in a way that feels wrong or worse. If anything, we're making the logic simpler and more consistent.
1 parent 1cf3c19 commit 55d279f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

syntax/parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ func (p *Parser) wordPart() WordPart {
13391339
}
13401340
return cs
13411341
case leftParen:
1342-
if p.lang.in(LangZsh) && p.r != ')' && (!p.spaced || p.quote == testExpr) {
1342+
if p.lang.in(LangZsh) && p.r != ')' {
13431343
// Zsh glob qualifier like *(N) or .(:a); the only case where
13441344
// ( immediately after a word is not a glob qualifier is ()
13451345
// for a function declaration, which the parser handles earlier.

syntax/parser_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ var errorCases = []errorCase{
994994
errCase(
995995
"for i in 1 2 (",
996996
langErr("1:14: word list can only contain words"),
997+
langErr("1:14: reached EOF without matching `(` with `)`", LangZsh),
997998
),
998999
errCase(
9991000
"for i in 1 2 3; do echo $i;",
@@ -1663,7 +1664,8 @@ var errorCases = []errorCase{
16631664
),
16641665
errCase(
16651666
"local (",
1666-
langErr("1:7: `local` must be followed by names or assignments", LangBash|LangZsh),
1667+
langErr("1:7: `local` must be followed by names or assignments", LangBash),
1668+
langErr("1:7: reached EOF without matching `(` with `)`", LangZsh),
16671669
),
16681670
errCase(
16691671
"declare 0=${o})",

0 commit comments

Comments
 (0)