diff options
author | 2023-05-14 20:55:54 -0700 | |
---|---|---|
committer | 2023-05-14 20:56:06 -0700 | |
commit | 328d09129ac78093c788aabda1724eb7c7379acc (patch) | |
tree | 1178d1bb529d4ce6c35df21eea69d34aca9e4c3c /src/js_parser.zig | |
parent | e096a03e3e7463e63d2338730e2387ddf6733f6c (diff) | |
download | bun-328d09129ac78093c788aabda1724eb7c7379acc.tar.gz bun-328d09129ac78093c788aabda1724eb7c7379acc.tar.zst bun-328d09129ac78093c788aabda1724eb7c7379acc.zip |
Fix scope chain bug
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r-- | src/js_parser.zig | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig index 34afc7b69..8a2d01a1c 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -2991,15 +2991,14 @@ pub const Parser = struct { // Move class export statements to the top of the file if we can // This automatically resolves some cyclical import issues // https://github.com/kysely-org/kysely/issues/412 - // TODO: this breaks code if they have any static variables or properties which reference anything from the parent scope - // we need to fix it before we merge v0.6.0 - var list = if (!p.options.bundle and class.class.canBeMoved()) &before else &parts; + const should_move = !p.options.bundle and class.class.canBeMoved(); + var sliced = try ListManaged(Stmt).initCapacity(p.allocator, 1); sliced.items.len = 1; sliced.items[0] = stmt; try p.appendPart(&parts, sliced.items); - if (&parts != list) { + if (should_move) { before.append(parts.getLast()) catch unreachable; parts.items.len -= 1; } @@ -3008,13 +3007,13 @@ pub const Parser = struct { // We move export default statements when we can // This automatically resolves some cyclical import issues in packages like luxon // https://github.com/oven-sh/bun/issues/1961 - var list = if (!p.options.bundle and value.canBeMoved()) &before else &parts; + const should_move = !p.options.bundle and value.canBeMoved(); var sliced = try ListManaged(Stmt).initCapacity(p.allocator, 1); sliced.items.len = 1; sliced.items[0] = stmt; try p.appendPart(&parts, sliced.items); - if (&parts != list) { + if (should_move) { before.append(parts.getLast()) catch unreachable; parts.items.len -= 1; } |