Skip to content

assignment_value_stale warning possible with function bindings #15550

@brunnerh

Description

@brunnerh

Describe the bug

This only happens in very specific circumstances, e.g. "binding" to a set-only property of a snippet argument.
The warning is not easy to understand in that context and will not happen with a regular property binding.

(The code behaves as expected so the warning feels like it might be a false positive.)

Reproduction

<script>
	let elementFunBind = $state();
	$inspect('fun', elementFunBind?.tagName);
	
	let elementPropBind = $state();
	$inspect('prop', elementPropBind?.tagName);

	let elementEvent = $state();
	$inspect('event', elementEvent?.tagName);
</script>

{#snippet funBind(context)}
	<!-- only this triggers the warning: -->
	<input value="via fun" bind:this={() => {}, e => context.element = e} />
{/snippet}
{@render funBind({ set element(e) { elementFunBind = e } })}

{#snippet propBind(context)}
	<textarea bind:this={context.element}>via prop</textarea>
{/snippet}
{@render propBind({ set element(e) { elementPropBind = e } })}

{#snippet event(context)}
	<button onclick={e => context.element = e.target}>via event</button>
{/snippet}
{@render event({ set element(e) { elementEvent = e } })}

Playground

Logs

System Info

REPL

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions