Skip to content

Svelte 5: unnecessary $.proxy() generated for += assignment #9966

@jeremy-deutsch

Description

@jeremy-deutsch

Describe the bug

When the Svelte 5 compiler sees a +=, it generates code like the following:
image
In this case, $.proxy() will always just return the value it’s passed, since it’s impossible for an addition expression in JS to return a non-primitive value. The compiler should probably just not wrap the expression in $.proxy() (though I get that the overhead and additional code size here is minor).

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE0WOwQrCMBBEfyUEDy0K6jW2gt9hPNR0C8F0E5KNICH_bpKCHmdm3-wkvmgDgYt74jitwAW_OccPnD6uivAGQ1B0sNGr6gxBee3oKlGSAWLKRiQ2sl2giaA79ZeSlGyJqEhbZBqVhxWQup6lmkjamP3IzvWYssTh-K_F4RmJCmlRGa1eY_pV5Pa2uUGw1HoavRHXMnS1s140zFyQj5Af-QvG9JrM4wAAAA==

Logs

No response

System Info

Svelte v5.0.0-next.26 (in Svelte 5 playground)

Severity

annoyance

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