Problem
.zi-load-object adds the nested load status to dynamically scoped ___retval, then returns the misspelled and normally undefined __retval.
Current source and caller:
|
# FUNCTION: .zi-load-object. [[[ |
|
.zi-load-object() { |
|
local ___type="$1" ___id=$2 |
|
local -a ___opt |
|
___opt=( ${@[3,-1]} ) |
|
if [[ $___type == snippet ]] { |
|
.zi-load-snippet $___opt "$___id" |
|
} elif [[ $___type == plugin ]] { |
|
.zi-load "$___id" "" $___opt |
|
} |
|
___retval+=$? |
|
return __retval |
|
} # ]]] |
|
ICE[cloneonly]="" |
|
} |
|
|
|
(( ___is_snippet )) && local ___opt="${(k)OPTS[*]}" || local ___opt="${${ICE[light-mode]+light}:-${OPTS[(I)-b]:+light-b}}" |
|
|
|
.zi-load-object ${${${(M)___is_snippet:#1}:+snippet}:-plugin} $___id $___opt |
|
integer ___last_retval=$? |
|
___retval+=___last_retval |
|
|
|
if (( ___turbo && !___had_cloneonly && ZI[HAVE_SCHEDULER] )) { |
|
command rm -f $___object_path/._zi/cloneonly |
|
unset 'ICE[cloneonly]' |
|
} |
|
} |
|
if (( ___turbo && ZI[HAVE_SCHEDULER] && 0 == ___last_retval )) { |
|
ICE[wait]="${ICE[wait]:-${ICE[service]:+0}}" |
|
if (( ___is_snippet > 0 )); then |
|
ZI_SICE[$___ehid]= |
|
.zi-submit-turbo s${ICE[service]:+1} "" "$___id" "${(k)OPTS[*]}" |
|
else |
|
ZI_SICE[$___ehid]= |
|
.zi-submit-turbo p${ICE[service]:+1} "${${${ICE[light-mode]+light}}:-load}" "$___id" "" |
Reproduction evidence
With .zi-load stubbed to return 7, a wrapper around .zi-load-object reported:
helper_rc=0 accumulated=7
The caller stores the false success in ___last_retval and uses it to decide whether turbo scheduling should proceed.
Impact
A failed immediate load can be treated as successful by later control flow, including scheduling another load attempt. The helper's result contract is also misleading to every future caller.
Acceptance criteria
- Make
.zi-load-object return the status of the load it performed.
- Accumulate that status exactly once in the caller.
- Do not fix this by returning the outer accumulator, which would double-count prior errors.
- Prevent turbo scheduling after an immediate load failure.
- Add focused plugin and snippet tests for success and failure paths.
Next action
Separate the helper's local result from the caller's aggregate result and capture both contracts in tests.
Problem
.zi-load-objectadds the nested load status to dynamically scoped___retval, then returns the misspelled and normally undefined__retval.Current source and caller:
zi/zi.zsh
Lines 1237 to 1249 in 7956627
zi/zi.zsh
Lines 2548 to 2569 in 7956627
Reproduction evidence
With
.zi-loadstubbed to return7, a wrapper around.zi-load-objectreported:The caller stores the false success in
___last_retvaland uses it to decide whether turbo scheduling should proceed.Impact
A failed immediate load can be treated as successful by later control flow, including scheduling another load attempt. The helper's result contract is also misleading to every future caller.
Acceptance criteria
.zi-load-objectreturn the status of the load it performed.Next action
Separate the helper's local result from the caller's aggregate result and capture both contracts in tests.