From f10878f644f3b8c51e9d2ab7dae6f4d79ced3abf Mon Sep 17 00:00:00 2001 From: John Chesley Date: Fri, 5 Apr 2019 22:01:17 -0400 Subject: [PATCH 1/2] add failing test for #2278 --- test/runtime/samples/function-hoisting/_config.js | 7 +++++++ .../runtime/samples/function-hoisting/main.svelte | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/runtime/samples/function-hoisting/_config.js create mode 100644 test/runtime/samples/function-hoisting/main.svelte diff --git a/test/runtime/samples/function-hoisting/_config.js b/test/runtime/samples/function-hoisting/_config.js new file mode 100644 index 0000000000..5a22ffaf0b --- /dev/null +++ b/test/runtime/samples/function-hoisting/_config.js @@ -0,0 +1,7 @@ +export default { + props: { + greeting: 'Good day' + }, + + html: '

Good day, world

' +} diff --git a/test/runtime/samples/function-hoisting/main.svelte b/test/runtime/samples/function-hoisting/main.svelte new file mode 100644 index 0000000000..109697193c --- /dev/null +++ b/test/runtime/samples/function-hoisting/main.svelte @@ -0,0 +1,15 @@ + + +

{greeting}, {hoistMeMaybe()}

From a26c7824aca6991b447e3d4c183237b8b19ed75d Mon Sep 17 00:00:00 2001 From: John Chesley Date: Fri, 5 Apr 2019 22:26:51 -0400 Subject: [PATCH 2/2] hoist all hoistable top-level functions --- src/compile/Component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 21f0b6ef05..ccd5da26f3 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -1023,7 +1023,7 @@ export default class Component { }; for (const [name, node] of top_level_function_declarations) { - if (!checked.has(node) && is_hoistable(node)) { + if (is_hoistable(node)) { const variable = this.var_lookup.get(name); variable.hoistable = true; hoistable_nodes.add(node);