Skip to content

Commit

Permalink
lib: further simplify assertions in vm/module
Browse files Browse the repository at this point in the history
Refs: #30755

PR-URL: #30815
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
addaleax authored and targos committed Jan 14, 2020
1 parent b6d09e8 commit 5dd9fb2
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/internal/vm/module.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { fail } = require('internal/assert');
const assert = require('internal/assert');
const {
ArrayIsArray,
ObjectCreate,
Expand Down Expand Up @@ -60,11 +60,6 @@ const kContext = Symbol('kContext');
const kPerContextModuleId = Symbol('kPerContextModuleId');
const kLink = Symbol('kLink');

function failIfDebug() {
if (process.features.debug === false) return;
fail('VM Modules');
}

class Module {
constructor(options) {
emitExperimentalWarning('VM Modules');
Expand Down Expand Up @@ -120,12 +115,11 @@ class Module {
importModuleDynamicallyWrap(options.importModuleDynamically) :
undefined,
});
} else if (syntheticEvaluationSteps) {
} else {
assert(syntheticEvaluationSteps);
this[kWrap] = new ModuleWrap(identifier, context,
syntheticExportNames,
syntheticEvaluationSteps);
} else {
failIfDebug();
}

wrapToModuleMap.set(this[kWrap], this);
Expand Down Expand Up @@ -381,7 +375,9 @@ class SyntheticModule extends Module {
identifier,
});

this[kLink] = () => this[kWrap].link(() => { failIfDebug(); });
this[kLink] = () => this[kWrap].link(() => {
assert.fail('link callback should not be called');
});
}

setExport(name, value) {
Expand Down

0 comments on commit 5dd9fb2

Please sign in to comment.