Fix crash if $PWD is used as for-loop variable

for PWD in foo; true; end

prints:

>..src/parse_execution.cpp:461: end_execution_reason_t parse_execution_context_t::run_for_statement(const ast::for_header_t&, const ast::job_list_t&): Assertion `retval == ENV_OK' failed.

because this used the wrong way to see if something is read-only.
This commit is contained in:
Fabian Homborg
2021-07-30 15:28:02 +02:00
parent 55732f445a
commit dd3cdbcfc9
2 changed files with 9 additions and 1 deletions

View File

@@ -500,3 +500,11 @@ echo banana
# This used to be a parse error - #7685.
echo (echo hello\\)
# CHECK: hello\
# Should fail because $PWD is read-only.
for PWD in foo bar
true
end
# CHECKERR: {{.*}}/basic.fish (line {{\d+}}): You cannot use read-only variable 'PWD' in a for loop
# CHECKERR: for PWD in foo bar
# CHECKERR: ^