You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
on:click={()=>{// No return statementf=function(item){// return item + 1;};}}
on:click={()=>{// No return statementf=item=>item+1;}}
on:click={()=>{// Function is not part of assigned expressionfunctionx(item){returnitem+1;};f=x;}}
on:click={()=>{// Assignment to local variableletf;f=function(item){returnitem+1;};}}
<script>// Hoisted out of templateletf=functionnoop(){}constclick=()=>{f=function(item){returnitem+1;};}</script><buttonon:click={click}>
Assign function
</button>
The text was updated successfully, but these errors were encountered:
trbrc
changed the title
"Unexpected token" when assigning of expression with function with return statement to non-local variable
"Unexpected token" when expression with function involving return statement is assigned to non-local variable
Jun 17, 2019
Found another requirement for reproducing this error, the return statement must be terminated with a semicolon (wtf?) REPL
This issue is probably related as well, doesn't result in a parse error, but there's also some weirdness with how the $$invalidate call is generated. REPL
I got
"Unexpected token (Note that you need plugins to import files that are not JavaScript)"
when I did something like this:After some experimentation to reduce it, the error seems to happen when an event handler has:
Example:
https://svelte.dev/repl/a10f29765022492085e8c2805fd095ef?version=3.5.1
Some variations that work:
The text was updated successfully, but these errors were encountered: