diff --git a/src/parse_util.cpp b/src/parse_util.cpp index 6cc381efb..10efed238 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -959,7 +959,7 @@ parser_test_error_bits_t parse_util_detect_errors_in_argument(const ast::argumen wcstring unesc; if (!unescape_string(arg_src.c_str() + begin, end - begin, &unesc, UNESCAPE_SPECIAL)) { if (out_errors) { - append_syntax_error(out_errors, source_start, L"Invalid token '%ls'", + append_syntax_error(out_errors, source_start + begin, L"Invalid token '%ls'", arg_src.c_str()); } return 1; diff --git a/tests/checks/syntax-error-location.fish b/tests/checks/syntax-error-location.fish index 3f2aebfdc..52ef3a3a9 100644 --- a/tests/checks/syntax-error-location.fish +++ b/tests/checks/syntax-error-location.fish @@ -39,6 +39,11 @@ $fish -c 'echo "unfinished "$(subshell' 2>| string replace -r '.*' '<$0>' # CHECK: # CHECK: < ^> +$fish -c 'echo "ok $(echo still ok)syntax error: \x"' 2>| string replace -r '.*' '<$0>' +# CHECK: +# CHECK: +# CHECK: < ^> + echo "function error" >$TMPDIR/error.fish $fish -c "set -g fish_function_path $(string escape $TMPDIR); error" # CHECKERR: ~/temp/error.fish (line 1): Missing end to balance this function definition @@ -47,6 +52,6 @@ $fish -c "set -g fish_function_path $(string escape $TMPDIR); error" # CHECKERR: from sourcing file ~/temp/error.fish # CHECKERR: source: Error while reading file '{{.*}}/error.fish' # CHECKERR: fish: Unknown command: error -# CHECKERR: fish: +# CHECKERR: fish: # CHECKERR: set -g fish_function_path {{.*}}; error # CHECKERR: ^