Restore error messages for bare variable assignment

Since #6287, bare variable assignments do not parse, which broke
the "Unsupported use of '='" error message.

This commit catches parse errors that occur on bare variable assignments.
When a statement node fails to parse, then we check if there is at least one
prefixing variable assignment. If so, we emit the old error message.

See also #6347
This commit is contained in:
Johannes Altmanninger
2019-11-25 09:19:53 +01:00
parent 563bdf3cc7
commit 97969a9363
3 changed files with 60 additions and 5 deletions

View File

@@ -76,3 +76,11 @@ complete -C'a=b xalias '
alias envxalias='a=b x'
complete -C'a=b envxalias '
# CHECK: arg
# Eval invalid grammar to allow fish to parse this file
eval 'a=(echo b)'
# CHECKERR: {{.*}}: Unsupported use of '='. In fish, please use 'set a (echo b)'.
eval ': | a=b'
# CHECKERR: {{.*}}: Unsupported use of '='. In fish, please use 'set a b'.
eval 'not a=b'
# CHECKERR: {{.*}}: Unsupported use of '='. In fish, please use 'set a b'.