diff --git a/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts b/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts
index 1b8e326a3..b65afe563 100644
--- a/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts
+++ b/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts
@@ -274,12 +274,7 @@ export function processInstanceScriptContent(
exportedNames.handleExportFunctionOrClass(node);
}
- if (ts.isBlock(node)) {
- pushScope();
- onLeaveCallbacks.push(() => popScope());
- }
-
- if (ts.isArrowFunction(node)) {
+ if (ts.isBlock(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
pushScope();
onLeaveCallbacks.push(() => popScope());
}
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/reactive-declare-same-name-as-function-parameter/expected.tsx b/packages/svelte2tsx/test/svelte2tsx/samples/reactive-declare-same-name-as-function-parameter/expected.tsx
new file mode 100644
index 000000000..5abfd09ee
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/reactive-declare-same-name-as-function-parameter/expected.tsx
@@ -0,0 +1,18 @@
+///
+<>>;function render() {
+
+const a = function (shadowed1) {}
+const b = (shadowed2) => {}
+let c = __sveltets_1_invalidate(() => function (shadowed3) {})
+let d = __sveltets_1_invalidate(() => (shadowed4) => {})
+
+let shadowed1 = __sveltets_1_invalidate(() => 1)
+let shadowed2 = __sveltets_1_invalidate(() => 1)
+let shadowed3 = __sveltets_1_invalidate(() => 1)
+let shadowed4 = __sveltets_1_invalidate(() => 1)
+;
+() => (<>>);
+return { props: {}, slots: {}, getters: {}, events: {} }}
+
+export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) {
+}
\ No newline at end of file
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/reactive-declare-same-name-as-function-parameter/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/reactive-declare-same-name-as-function-parameter/expectedv2.ts
new file mode 100644
index 000000000..7a2dde8f9
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/reactive-declare-same-name-as-function-parameter/expectedv2.ts
@@ -0,0 +1,18 @@
+///
+;function render() {
+
+const a = function (shadowed1) {}
+const b = (shadowed2) => {}
+let c = __sveltets_1_invalidate(() => function (shadowed3) {})
+let d = __sveltets_1_invalidate(() => (shadowed4) => {})
+
+let shadowed1 = __sveltets_1_invalidate(() => 1)
+let shadowed2 = __sveltets_1_invalidate(() => 1)
+let shadowed3 = __sveltets_1_invalidate(() => 1)
+let shadowed4 = __sveltets_1_invalidate(() => 1)
+;
+async () => {};
+return { props: {}, slots: {}, getters: {}, events: {} }}
+
+export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) {
+}
\ No newline at end of file
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/reactive-declare-same-name-as-function-parameter/input.svelte b/packages/svelte2tsx/test/svelte2tsx/samples/reactive-declare-same-name-as-function-parameter/input.svelte
new file mode 100644
index 000000000..ab090f154
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/reactive-declare-same-name-as-function-parameter/input.svelte
@@ -0,0 +1,11 @@
+
\ No newline at end of file