Skip to content

Commit b7d5974

Browse files
committed
bugfix in fn merge_tables
1 parent e76f37d commit b7d5974

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/compiler/utils/string_with_sourcemap.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,16 @@ function merge_tables<T>(
5959
): { table: T[]; new_idx: number[] } {
6060
const table = original.slice();
6161
const new_idx = [];
62-
for (let j = 0; j < original.length; j++) {
63-
const current = extended[j];
64-
const existing = table.indexOf(current);
65-
if (existing < 0) {
66-
table.push(current);
67-
new_idx[j] = table.length - 1;
68-
} else {
69-
new_idx[j] = existing;
62+
if (extended) {
63+
for (let j = 0; j < extended.length; j++) {
64+
const current = extended[j];
65+
const existing = table.indexOf(current);
66+
if (existing == -1) {
67+
table.push(current);
68+
new_idx[j] = table.length - 1;
69+
} else {
70+
new_idx[j] = existing;
71+
}
7072
}
7173
}
7274
return { table, new_idx };

0 commit comments

Comments
 (0)