From 5dd9fb2ef5bca2f143b14752cf7b9ca8bbf07c15 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 6 Dec 2019 01:09:09 +0100 Subject: [PATCH] lib: further simplify assertions in vm/module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/pull/30755 PR-URL: https://github.com/nodejs/node/pull/30815 Reviewed-By: Ruben Bridgewater Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso --- lib/internal/vm/module.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/internal/vm/module.js b/lib/internal/vm/module.js index e9e8b1346264a9..d12362184a5051 100644 --- a/lib/internal/vm/module.js +++ b/lib/internal/vm/module.js @@ -1,6 +1,6 @@ 'use strict'; -const { fail } = require('internal/assert'); +const assert = require('internal/assert'); const { ArrayIsArray, ObjectCreate, @@ -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'); @@ -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); @@ -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) {