Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assignment_value_stale warning possible with function bindings #15550

Closed
brunnerh opened this issue Mar 19, 2025 · 0 comments · Fixed by #15644
Closed

assignment_value_stale warning possible with function bindings #15550

brunnerh opened this issue Mar 19, 2025 · 0 comments · Fixed by #15644

Comments

@brunnerh
Copy link
Member

brunnerh commented Mar 19, 2025

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

@brunnerh brunnerh changed the title assignment_value_stale error possible with read-only function bindings assignment_value_stale error possible with function bindings Mar 19, 2025
@brunnerh brunnerh changed the title assignment_value_stale error possible with function bindings assignment_value_stale warning possible with function bindings Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant