Skip to content

Commit 252fd78

Browse files
committed
remove duplicate put, add more assertions
1 parent b692c5d commit 252fd78

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/runtime/js.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
850850

851851
const arena = self.context_arena;
852852
const owned_url = try arena.dupe(u8, url);
853+
853854
try self.module_identifier.putNoClobber(arena, m.getIdentityHash(), owned_url);
854855
errdefer _ = self.module_identifier.remove(m.getIdentityHash());
855856

@@ -900,7 +901,6 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
900901
.resolver_promise = null,
901902
};
902903
}
903-
try self.module_identifier.put(arena, m.getIdentityHash(), owned_url);
904904
return if (comptime want_result) gop.value_ptr.* else {};
905905
}
906906

@@ -1763,6 +1763,8 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
17631763
// We need to do part of what the first case is going to do in
17641764
// `dynamicModuleSourceCallback`, but we can skip some steps
17651765
// since the module is alrady loaded,
1766+
std.debug.assert(gop.value_ptr.module != null);
1767+
std.debug.assert(gop.value_ptr.module_promise != null);
17661768

17671769
// like before, we want to set this up so that if anything else
17681770
// tries to load this module, it can just return our promise
@@ -1818,6 +1820,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
18181820
std.debug.assert(module_entry.module != null);
18191821
std.debug.assert(module_entry.module_promise != null);
18201822
std.debug.assert(module_entry.resolver_promise != null);
1823+
std.debug.assert(self.module_cache.contains(state.specifier));
18211824

18221825
// We've gotten the source for the module and are evaluating it.
18231826
// You might thing we're done, but the module evaluation is

0 commit comments

Comments
 (0)