diff --git a/src/compiler/compile/render_dom/Renderer.ts b/src/compiler/compile/render_dom/Renderer.ts
index 29389ed3c3d8..035b47e74f7c 100644
--- a/src/compiler/compile/render_dom/Renderer.ts
+++ b/src/compiler/compile/render_dom/Renderer.ts
@@ -220,7 +220,11 @@ export default class Renderer {
const i = (value / 31) | 0;
const n = 1 << (value % 31);
- if (!bitmask[i]) bitmask[i] = { n: 0, names: [] };
+ if (bitmask.length <= i) {
+ for (let j = bitmask.length; j <= i; j++) {
+ bitmask[j] = { n: 0, names: [] };
+ }
+ }
bitmask[i].n |= n;
bitmask[i].names.push(name);
diff --git a/test/runtime/samples/bitmask-overflow-3/_config.js b/test/runtime/samples/bitmask-overflow-3/_config.js
new file mode 100644
index 000000000000..13f18b386cb2
--- /dev/null
+++ b/test/runtime/samples/bitmask-overflow-3/_config.js
@@ -0,0 +1,4 @@
+export default {
+ solo: true,
+ error: `A is not defined`,
+};
\ No newline at end of file
diff --git a/test/runtime/samples/bitmask-overflow-3/main.svelte b/test/runtime/samples/bitmask-overflow-3/main.svelte
new file mode 100644
index 000000000000..aa2c56a14759
--- /dev/null
+++ b/test/runtime/samples/bitmask-overflow-3/main.svelte
@@ -0,0 +1,4 @@
+
+foo