Skip to content

fix(load): return the actual object-load status #446

Description

@ss-o

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:

  • zi/zi.zsh

    Lines 1237 to 1249 in 7956627

    # 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
    } # ]]]
  • zi/zi.zsh

    Lines 2548 to 2569 in 7956627

    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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ziZi core behavior, APIs, or documentation.priority:highNeeds prompt attention.type:bugSomething is broken or behaving incorrectly.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions