From 0f8b9699a1baf0d819de00cf77dbecc233b5e077 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 15 Nov 2022 19:02:30 +0100 Subject: [PATCH] Fix error for {$} Fixes #9337 --- src/parse_util.cpp | 6 ++++++ tests/checks/syntax-error-location.fish | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/parse_util.cpp b/src/parse_util.cpp index 63903ae7b..dc09d3071 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -866,6 +866,12 @@ static const wchar_t *error_format_for_character(wchar_t wc) { case VARIABLE_EXPAND_EMPTY: { return ERROR_NOT_PID; } + case BRACE_END: + case L'}': + case L',': + case BRACE_SEP: { + return ERROR_NO_VAR_NAME; + } default: { return ERROR_BAD_VAR_CHAR1; } diff --git a/tests/checks/syntax-error-location.fish b/tests/checks/syntax-error-location.fish index 42b06a92d..f5a432454 100644 --- a/tests/checks/syntax-error-location.fish +++ b/tests/checks/syntax-error-location.fish @@ -55,3 +55,13 @@ $fish -c "set -g fish_function_path $(string escape $TMPDIR); this_should_be_an_ # CHECKERR: fish: # CHECKERR: set -g fish_function_path {{.*}}; this_should_be_an_error # CHECKERR: ^~~~~~~~~~~~~~~~~~~~~~^ + +$fish -c 'echo {$}' +# CHECKERR: fish: Expected a variable name after this $. <= no more checks +# CHECKERR: echo {$} +# CHECKERR: ^ + +$fish -c 'echo {$,}' +# CHECKERR: fish: Expected a variable name after this $. +# CHECKERR: echo {$,} +# CHECKERR: ^