Skip to content

[Svelte 5] array pop will trigger Uncaught TypeError #9920

@jirihon

Description

@jirihon

Describe the bug

Clicking on push and then pop will trigger Uncaught TypeError: Cannot read properties of undefined (reading 'id')

<script>
    let numbers = $state([{id: 1}, {id: 2}, {id: 3}]);
</script>

<button onclick={() => numbers.push({id: numbers.length + 1})}>
    push
</button>

<button onclick={() => numbers.pop()}>
    pop
</button>

{#each numbers as number}
    <p>{number.id}</p>
{/each}

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAA42PwWrDMBBEf0Vse7CpiUl7c2VDvyPKwZE3tYi8EtaqUIT-vcipW-ipt5lh5rGb4GosBuhOCWhcEDp48x4a4E9fTPhAywgNBBdXXRIZ9Go8D4oUW2RBcbngGkQvHgOPjNUpmakTx9yITTzv4iWf61dFsv0FkLxEZkfCkbZG3_pU1aIfdubBxzBX23hPLNI7z-JJHHOdtxtKp1DvpH9Rna_2sfN_tukBRz3_fDWGb5lLXfoh3e3BTFm2flCU2jLIiqCBxU3manCCjteI-Zy_AKDUYs1fAQAA

Logs

No response

System Info

svelte-5-preview.vercel.app

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions