mirror of https://github.com/sveltejs/svelte
Use separate scopes for function declarations/expressions and function bodies. This prevents variable declarations from leaking into default parameter initialization expressions. Closes #17785.pull/17788/head
parent
fcdc0289db
commit
b6e386ee08
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: handle default parameters scope leaks
|
||||
@ -0,0 +1,7 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, logs }) {
|
||||
assert.deepEqual(logs, [42, 43]);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
let value = $state(42);
|
||||
|
||||
function shadow(output = value) {
|
||||
const value = 1337;
|
||||
return output;
|
||||
}
|
||||
|
||||
console.log(shadow());
|
||||
value += 1;
|
||||
console.log(shadow());
|
||||
</script>
|
||||
Loading…
Reference in new issue