mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +00:00
Make string syntax error location a bit more precise
String tokens are subdivided by command substitutions. Some syntax errors can occur in the gap between two command substitutions. Make the caret point to the start of that gap, instead of the token start.
This commit is contained in:
parent
e717b13e75
commit
4b5b56452b
2 changed files with 7 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -39,6 +39,11 @@ $fish -c 'echo "unfinished "$(subshell' 2>| string replace -r '.*' '<$0>'
|
|||
# CHECK: <echo "unfinished "$(subshell>
|
||||
# CHECK: < ^>
|
||||
|
||||
$fish -c 'echo "ok $(echo still ok)syntax error: \x"' 2>| string replace -r '.*' '<$0>'
|
||||
# CHECK: <fish: Invalid token '"ok $(echo still ok)syntax error: \x"'>
|
||||
# CHECK: <echo "ok $(echo still ok)syntax error: \x">
|
||||
# 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
|
||||
|
|
Loading…
Reference in a new issue