Skip to content

Commit 5dd9fb2

Browse files
addaleaxtargos
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 b6d09e8 commit 5dd9fb2

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,
@@ -60,11 +60,6 @@ const kContext = Symbol('kContext');
6060
const kPerContextModuleId = Symbol('kPerContextModuleId');
6161
const kLink = Symbol('kLink');
6262

63-
function failIfDebug() {
64-
if (process.features.debug === false) return;
65-
fail('VM Modules');
66-
}
67-
6863
class Module {
6964
constructor(options) {
7065
emitExperimentalWarning('VM Modules');
@@ -120,12 +115,11 @@ class Module {
120115
importModuleDynamicallyWrap(options.importModuleDynamically) :
121116
undefined,
122117
});
123-
} else if (syntheticEvaluationSteps) {
118+
} else {
119+
assert(syntheticEvaluationSteps);
124120
this[kWrap] = new ModuleWrap(identifier, context,
125121
syntheticExportNames,
126122
syntheticEvaluationSteps);
127-
} else {
128-
failIfDebug();
129123
}
130124

131125
wrapToModuleMap.set(this[kWrap], this);
@@ -381,7 +375,9 @@ class SyntheticModule extends Module {
381375
identifier,
382376
});
383377

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

387383
setExport(name, value) {

0 commit comments

Comments
 (0)