Fix error offset for command (foo)

This used the decorated statement offset when the expansion errors
refer to the command without decoration.
This commit is contained in:
Fabian Boehm 2022-08-11 18:06:05 +02:00
parent a4fd3c194e
commit eaf92918e6
2 changed files with 8 additions and 5 deletions

View file

@ -1225,7 +1225,10 @@ static bool detect_errors_in_decorated_statement(const wcstring &buff_src,
} }
if (parse_errors) { if (parse_errors) {
parse_error_offset_source_start(&new_errors, source_start); // The expansion errors here go from the *command* onwards,
// so we need to offset them by the *command* offset,
// excluding the decoration.
parse_error_offset_source_start(&new_errors, dst.command.source_range().start);
vec_append(*parse_errors, std::move(new_errors)); vec_append(*parse_errors, std::move(new_errors));
} }
} }

View file

@ -324,8 +324,8 @@ $fish -c 'echo {}}'
#CHECKERR: fish: Unexpected '}' for unopened brace expansion #CHECKERR: fish: Unexpected '}' for unopened brace expansion
#CHECKERR: echo {}} #CHECKERR: echo {}}
#CHECKERR: ^ #CHECKERR: ^
$fish -c 'command (asd)' printf '<%s>\n' ($fish -c 'command (asd)' 2>&1)
#CHECKERR: fish: Command substitutions not allowed #CHECK: <fish: Command substitutions not allowed>
#CHECKERR: command (asd) #CHECK: <command (asd)>
#CHECKERR: ^ #CHECK: < ^~~~^>
true true