Skip to content

Commit 614b2c5

Browse files
addaleaxBridgeAR
authored andcommitted
lib: further simplify assertions in vm/module
Refs: #30755 PR-URL: #30815 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 7e13ae7 commit 614b2c5

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/internal/vm/module.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { fail } = require('internal/assert');
3+
const assert = require('internal/assert');
44
const {
55
ArrayIsArray,
66
ObjectCreate,
@@ -59,11 +59,6 @@ const kContext = Symbol('kContext');
5959
const kPerContextModuleId = Symbol('kPerContextModuleId');
6060
const kLink = Symbol('kLink');
6161

62-
function failIfDebug() {
63-
if (process.features.debug === false) return;
64-
fail('VM Modules');
65-
}
66-
6762
class Module {
6863
constructor(options) {
6964
emitExperimentalWarning('VM Modules');
@@ -119,12 +114,11 @@ class Module {
119114
importModuleDynamicallyWrap(options.importModuleDynamically) :
120115
undefined,
121116
});
122-
} else if (syntheticEvaluationSteps) {
117+
} else {
118+
assert(syntheticEvaluationSteps);
123119
this[kWrap] = new ModuleWrap(identifier, context,
124120
syntheticExportNames,
125121
syntheticEvaluationSteps);
126-
} else {
127-
failIfDebug();
128122
}
129123

130124
wrapToModuleMap.set(this[kWrap], this);
@@ -380,7 +374,9 @@ class SyntheticModule extends Module {
380374
identifier,
381375
});
382376

383-
this[kLink] = () => this[kWrap].link(() => { failIfDebug(); });
377+
this[kLink] = () => this[kWrap].link(() => {
378+
assert.fail('link callback should not be called');
379+
});
384380
}
385381

386382
setExport(name, value) {

0 commit comments

Comments
 (0)