Describe the bug
When a prop is declared and its default value contain assignment, the compiler will throw up.
Logs
Error: TODO this should not happen!
at dom (/ceres/node_modules/svelte/compiler.js:17865:20)
at compile (/ceres/node_modules/svelte/compiler.js:23840:16)
at preprocessPromise.then.code (/ceres/node_modules/rollup-plugin-svelte/index.js:252:22)
at process._tickCallback (internal/process/next_tick.js:68:7)
To Reproduce
Can be reproduced in REPL:
<script>
let name = 'world';
let something;
export let prop = (something = 1);
</script>
<h1>Hello {name}!</h1>
You get the TODO this should not happen message at REPL bottom.
I was actually using rollup and preprocessed svelte files with babel to get optional chaining syntax support. I got this "TODO" error when I wrote something like export let x = a?.b. I eventually discovered that the optional chaining will transpile into code with in expression assignments. The assignment is what actually killed svelte compiler.
Expected behavior
Just work as it should be.
Information about your Svelte project:
Severity
Not quite severe, but the error tip is frustrating. It doesn't tell me what's wrong or where to fix. I wasted an hour to find out the cause.
This isn't restricted to props. This also throws that error:
<script>
let foo;
let bar = foo = 1;
</script>
as does this example based on #3393:
<script>
let foo;
let bar = foo++;
</script>
Interestingly, this is fine:
<script>
let foo;
let bar;
bar = foo = 1;
</script>
I think i can fix it
Update 18.08.2019
still work =)
Update 20.08.2019
found solution, mr in progress
This was fixed back in 3.10.0